191920
191920

Reputation: 63

Is there a function to skip steps in a for loop?

I want to skip steps in a nested for loops of like 9 loops but the code will express my question and predicament:

Sub question()
    For x = 0 To 10
        For y = 0 To 10
            If x = 5 And y = 7 Then
                'skip to x = 8
            End If
        Next
    Next
End Sub

Upvotes: 0

Views: 147

Answers (1)

Stefano Balzarotti
Stefano Balzarotti

Reputation: 1904

Just set x = 8

Sub Question()
    Dim x As Integer
    Dim y As Integer
    For x = 0 To 10
        For y = 0 To 10
            If x = 5 And y = 7 Then
                x = 8
            End If
        Next
    Next
End Sub

Upvotes: 1

Related Questions