Do While Loop在VBA中没有停止

时间:2017-01-13 12:25:31

标签: excel excel-vba do-while vba

我有一个简单的循环,但在条件满足后我无法阻止它!

我有一个循环正在排序的大量数据列表。 EndRow变量设置为最后一行,CurRow变量设置为当前行,并且在每个循环中递增。我希望它在到达列表末尾时停止(即CurRow = EndRow),但它并没有停止!简单的错误我确定,但我看不到它!

    Dim i As Integer
Dim j As Integer
Dim CurRow As Integer
Dim EndRow As Integer

EndRow = Range("A" & Rows.Count).End(xlUp).Row
CurRow = 1
i = 1

Do While CurRow < EndRow

    If Cells(CurRow, 1).Value = "BEGIN:VEVENT" Then
        j = 5
        CurRow = CurRow + 1
        Do Until Cells(CurRow, 1).Value = "BEGIN:VEVENT"

            Cells(i, j) = Cells(CurRow, 1)
            j = j + 1
            CurRow = CurRow + 1
        Loop
        i = i + 1

    Else
        CurRow = CurRow + 1
    End If


Loop

0 个答案:

没有答案