View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
cate cate is offline
external usenet poster
 
Posts: 93
Default short circuit for next; continue?

On Jan 31, 9:10*am, "JLGWhiz" wrote:
Not sure I understand what you mean, but I think maybe Exit For is what you
are looking for.
For i = 1 To 10
* If condition is met then
* * *Exit For
* End If
* 'Do stuff
Next
The Exit for will take you out of the loop to the next line of code.

"cate" wrote in message

...

Is there a way to do this in vba? *(I can do this with structure but I
want to know if there is a perl/C# analog to (continue")


for x = 2 to y


*answer = sub_testing()
*if answer = 1
* *continue *' skip the reset of loop code and go back and get the
next value. *No point in going on
*end if


*do more stuff
*do more stuff


next


thank you.


With if's it would look like this

For i = 1 To 10
If condition is met then
do stuff
end if
Next

verses (with continue) The same result

For i = 1 To 10
If condition is NOT met then
continue
end if
do stuff
Next