Jumping Out of Nested Statements
Sub test()
For Each cell In ActiveSheet.Range("a1:a50")
cell.Select
If cell.Row = 5 Then Exit For
Next cell
End Sub
-----Original Message-----
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
.
|