我有一個Excel VBA程序,循環訪問數據表中的每行數據。在VBA/VBS中退出while循環
我的目標是一旦布爾型bFound
設置爲True
就退出while循環。
我想我的條件「或bFound = True」可能不正確。
bFound = False
While Sheets("Data").Cells(iRow, 1) <> "" Or bFound = True
If Sheets("Data").Cells(iRow, 11) = Sheets("Data2").Cells(iRow, 1) Then
bFound = True
End If
iRow = iRow + 1
Wend
'exit loop after the boolean=true
更換**或**與**而* * –
[在VBS/VBA中退出while循環]的可能重複(http://stackoverflow.com/questions/1271949/exit-a-while-loop-in-vbs-vba) – Selfish