I am using a While...Wend loop of VBA.
Dim count as Integer
While True
count=count+1
If count = 10 Then
''What should be the statement to break the While...Wend loop?
''Break or Exit While not working
EndIf
Wend
I don't want to use condition like `While count<=10...Wend
This question is related to
excel
vba
while-loop
Another option would be to set a flag variable as a Boolean
and then change that value based on your criteria.
Dim count as Integer
Dim flag as Boolean
flag = True
While flag
count = count + 1
If count = 10 Then
'Set the flag to false '
flag = false
End If
Wend
The best way is to use an And
clause in your While
statement
Dim count as Integer
count =0
While True And count <= 10
count=count+1
Debug.Print(count)
Wend
Source: Stackoverflow.com