Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42220

Exit one level up nested For...Next

$
0
0
Hi Guys!

I am pretty sure it is impossible but I want to ask it, anyway:
I have
Code:

For n = 0 To 5 'The values are not important.
For m = 1 To 6 'The values are not important.
.
.'Do Something
.
Next m
'Do some other stuff
Next n

I want to go to Next n if something happens in For..m..Next
Code:

For n = 0 To 5 'The values are not important.
For m = 1 To 6 'The values are not important.
.
If something happens Then
Next n 'Here is the impossible part.
End If
.
Next m
'Do some other stuff
Next n

My solution is
Code:

For n = 0 To 5 'The values are not important.
For m = 1 To 6 'The values are not important.
.
If something happens Then
GoTo Skip
End If
.
Next m
'Do some other stuff
Skip:
Next n

But I am looking for something better because I am not sure if GoTo slows my code or not.

Any idea?
Thanks a lot!

Viewing all articles
Browse latest Browse all 42220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>