Excel VBA--退出for循环
我想在满足内部条件时退出我的for
循环。当 "if "条件得到满足时,我怎样才能退出我的 "for "循环?我想在 "if "语句的末尾有某种退出方式,但不知道该如何操作。
Dim i As Long
For i = 1 To 50
Range("B" & i).Select
If Range("B" & i).Value = "Artikel" Then
Dim temp As Long
temp = i
End If
Next i
Range("A1:Z" & temp - 1).EntireRow.Delete Shift:=xlToLeft
168
2
要提前退出你的循环,你可以使用 "Exit For"。
如果[条件],则退出For"。
另一种提前退出For循环的方法是通过改变循环计数器。