使用来自不同工作表的两个单元格设置范围

时间:2018-01-26 12:21:41

标签: excel vba for-loop range worksheet

我试图通过日历为每列设置一个移动的13天范围。如果13天的范围超过当月,我希望能够转到下一张表,并找到我结束的地方。但是,我不能同时引用这两张纸。 Set rng13 = .Range(start13, finish13)

我计划在13天的范围内运行布尔检查,看看是否所有13天都是真的。

任何帮助或建议都将不胜感激

With ActiveWorkbook.Worksheets(i)
    Set onePersonLoop = .Cells(rowNum, colNum).Offset(-1).End(xlToRight).Offset(, -2)
    Set onePersonLoop = .Cells(rowNum, colNum).Offset(-1).End(xlToRight).Offset(, -2)

    For rowNum = 6 To 24 Step 6
        Set nameLocation = .Cells(rowNum, colNum).Offset(-2, -1).EntireRow.Cells(1, 2)
        For colNum = 4 To onePersonLoop.
            Set start13 = .Cells(rowNum, colNum)
            If start13.Column <= onePersonLoop.Column - 12 Then
                Set finish13 = .Cells(rowNum, colNum + 12)
            ElseIf start13.Column > onePersonLoop.Column - 12 Then
                carryOver = start13.Column - (onePersonLoop.Column - 12)
                Worksheets(i + 1).Activate
                Set finish13 = Worksheets(i + 1).Cells(rowNum, 3 + carryOver)
                Set rng13 = .Range(start13, finish13)
            End If
        Next colNum
    Next rowNum
End With

0 个答案:

没有答案