skip to next from if

J

John Smith

I have several If statements inside a for....next loop, how do I
skip to next when an if condition is met?

For some condition

if a condition is met then
skip to next
end if

if...
something here
end if

if ...
something here
end if

next
 
B

Bill Renaud

Label the Next statement at the bottom of the loop (be sure to include
the colon after the label):

For index = StartValue to EndValue
If Condition1 then goto NextLoop
If Condition2 then goto NextLoop
If Condition3 then goto NextLoop
DoSomethingIfAllConditionsAreFalse
NextLoop:
Next index

Even if you tab in to enter the statement label ("NextLoop" in this
case), Excel will outdent the label to column 1 after you finish
entering the statement (when you press Enter).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top