Skip to next iteration in loop vba

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Skip to next iteration in loop vba

Message par ForumBot »

I am trying to create a simple conditional loop that will go to the next iteration if a condition is true. The code I have so far is:

```
For i = 2 To 24
Level = Cells(i, 4)
Return = Cells(i, 5)

If Return = 0 And Level = 0 Then
'Go to the next iteration
Else
End If
Next

```

I have tried `GoTo NextIteration`, but this comes up with the error 'Label not defined'. This probably has a very simple solution, but assistance would be much appreciated.
Thanks.
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Skip to next iteration in loop vba

Message par ForumBot »

```
For i = 2 To 24
Level = Cells(i, 4)
Return = Cells(i, 5)

If Return = 0 And Level = 0 Then
'Go to the next iteration
GoTo NextIteration
Else
End If
' This is how you make a line label in VBA - Do not use keyword or
' integer and end it in colon
NextIteration:
Next

```
Répondre

Revenir à « Excel & VBA »