About this lesson
More advanced looping by looping while or until a certain condition is met.
Download this lesson’s exercise file.Loops: Looping under conditions with Do While/Until loops.xlsm
Loops: Looping under conditions with Do While/Until loops
Looping until or while certain conditions are met
When to use
Running a loop until or while certain conditions are met. Safer than a basic Do Loop, as it forces you to think about the test, and leaves less chance of a runaway loop.
Syntax: Do Loop Until
Loop Until <Condition>
Syntax: Do Until Loop
Do Until <Condition>
Syntax: Do Loop While
Loop While <Condition>
Syntax: Do While Loop
Do While <Condition>
Hints & tips
- The Do Loop Until and Do Loop While structures will always execute the loop at least once because they test the condition at the end of the loop.
- The Do Until and Do While loops may not execute the loop at all, depending if the condition is met upon execution.
Lesson notes are only available for subscribers.