我试图使用“继续”语句跳到 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
有什么想法吗? 谢谢..
最佳答案
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
或
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
<小时/>
注意:在这两个版本中,我都将 IsEmpty(xlSheet.Cells(row, 1))
更改为 IsEmpty(xlSheet.Cells(row + 1, 1))
或否则你将陷入无限循环。
关于vba - Excel VBA - 如何在 Do Until...循环中跳到下一次迭代,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39867524/