循环基于特定细胞

时间:2017-07-25 22:56:07

标签: excel vba loops

你好我有一个宏,它循环遍历G列中的单元格,首先将每个单元格转为TRUE,然后沿着列向下移动。

这是我想要实施的改变。单元格F11到F21具有1到4.如果单元格F1,F3和F5具有1,则我希望列G1,G3和G5中的相邻单元格需要为TRUE。然后移动到具有2然后是3然后4

的单元格
Sub CF_Macro()
'
' CF_Macro Macro
'
Sub SpitValues()

Dim wsInput As Worksheet
Set wsInput = Worksheets("Repline Input")

Dim wsSummary As Worksheet
Set wsSummary = Worksheets("Summary")

With wsInput

    .Range("G11").Resize(10, 1).Value = "FALSE"

    Dim rCell As Range
    For Each rCell In .Range("G11").Resize(10, 1)

        rCell.Value = "TRUE"

        DoEvents
        'Application.Wait (Now + TimeValue("0:00:05"))
        wsSummary.Range("b13:b16").Copy
        wsSummary.Range("z1").Select
        Selection.End(xlToLeft).Offset(ColumnOffset:=1).PasteSpecial xlPasteValues
        rCell.Value = "FALSE"

    Next

End With

1   TRUE
2   FALSE
3   FALSE
4   FALSE
1   TRUE
2   FALSE
3   FALSE
4   FALSE
1   TRUE
2   FALSE

0 个答案:

没有答案