仅用于循环表,但实际上不是表

时间:2018-01-31 08:46:13

标签: excel excel-vba vba

For b = 6 To .Cells(.Rows.Count, "A").End(xlDown).Row

我想检查从A8开始到表格内的每一行。请参阅附图。我怎样才能做到这一点?

Table like this

1 个答案:

答案 0 :(得分:0)

这将向您展示如何引用A6A7,考虑到您的逻辑如下:&#34;从6开始并在第一个空行前完成&#34;:< / p>

    With Worksheets(1)        
        For cnt = 6 To .Cells(6, "A").End(xlDown).Row
            Debug.Print cnt
        Next cnt        
    End With

如果6被确定为&#34;第一个单元格在第一个空单元格之后的值为#34;那么类似的东西将是有用的:

Public Sub TestMe()

    Dim start   As Long
    Dim cnt     As Long

    With Worksheets(1)        
        start = .Cells(1, "A").End(xlDown).End(xlDown).Row
        For cnt = start To .Cells(start, "A").End(xlDown).Row
            Debug.Print cnt
        Next cnt
    End With

End Sub