skip to next from if

  • Thread starter Thread starter John Smith
  • Start date Start date
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
 
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).
 
Back
Top