View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Jumping Out of Nested Statements

use a label

For each x in range
if x then
..
if y then goto loopNext
..
end if

loopNext:
next


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


?B?U3RyYXR1c2Vy?= wrote :

I don't want to exit the For loop, I just want to go to the next item
in the range.

"Stratuser" wrote:

I have a block containing several levels of nested statements within
a For Each...Next loop. I'm using a GoTo statement to make execution
jump to the end of the loop. It works, but I'm wondering if there
isn't a better way to do this, because I've read that you should not
use line numbers to jump around inside a subroutine. Any ideas?
Here's the structure of the code:

For Each X in Range("TickerList")
If ....
With .....
Select Case True
Case ...

Case ...
If ....
GoTo 15 'from here i want to
jump
to Next X
End If
End Select
End With
End If
Next X