Excel VBA - 退出循环 [英] Excel VBA - exit for loop
本文介绍了Excel VBA - 退出循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在满足内部条件时退出我的 for
循环.当满足 if
条件时,我如何退出我的 for
循环?我认为在我的 if
语句末尾有某种退出,但不知道它会如何工作.
I would like to exit my for
loop when a condition inside is met. How could I exit my for
loop when the if
condition has been met? I think some kind of exit at the end of my if
statement, but don't know how that would work.
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
推荐答案
要提前退出循环,您可以使用 Exit For
To exit your loop early you can use Exit For
If [condition] Then Exit For
这篇关于Excel VBA - 退出循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文