| title | Loop Control |
|---|---|
| parent | Language Syntax |
| nav_order | 12 |
| permalink | /Features/Language/Loop-Control |
The following new statements are available for controlling the procession of loops:
Continue For- Proceed to the next iteration (or end) ofForloop.Continue While- Proceed to the next iteration (or end) ofWhileloop.Continue Do- Proceed to the next iteration ofDoloop.Exit While- Exit aWhileloop immediately.
Dim i As Long
For i = 1 To 10
If i Mod 2 = 0 Then Continue For ' skip even numbers
If i > 7 Then Exit For ' stop before reaching 8
Debug.Print i
Next
' prints: 1, 3, 5, 7