View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\) Rick Rothstein \(MVP - VB\) is offline
external usenet poster
 
Posts: 2,202
Default Does VBA have a "continue" statement like C?

I would like to write:

for each ...
if ... then continue
... rest of for loop ...
next ...

Of course, I could write:

for each ...
if not ... then
... rest of for loop ...
end if
next ...

But I prefer the style of the first form.


VB doesn't have a Continue statement. You can imitate one like this...

For Each ....
If .... Then Goto Continue1
.... <<rest of loop
Continue1:
Next

Note that I used a number on the end because if you have more than one
situation where you want the Continue, your Labels that you GoTo must be
uniquely named.

Rick