我正在尝试使用“继续”语句跳到我的 vba 代码中的下一次迭代。它不工作..
Do Until IsEmpty(xlSheet.Cells(row, 1))
row = row + 1
If xlSheet.Cells(row, 2) = "Epic" Then
Continue
End If
xlSheet.Cells(row, 1).Value = 5
Loop
Run Code Online (Sandbox Code Playgroud)
任何的想法??谢谢..
VBA 没有Continue声明。你可以通过做类似的事情来解决它
Do Until IsEmpty(xlSheet.Cells(row + 1, 1))
row = row + 1
If xlSheet.Cells(row, 2) <> "Epic" Then
xlSheet.Cells(row, 1).Value = 5
End If
Loop
Run Code Online (Sandbox Code Playgroud)
或者
Do Until IsEmpty(xlSheet.Cells(row + 1, 1))
row = row + 1
If xlSheet.Cells(row, 2) = "Epic" Then
GoTo ContinueDo
End If
xlSheet.Cells(row, 1).Value = 5
ContinueDo:
Loop
Run Code Online (Sandbox Code Playgroud)
注意:在我更改的两个版本中IsEmpty(xlSheet.Cells(row, 1)),IsEmpty(xlSheet.Cells(row + 1, 1))否则您最终会陷入无限循环。