Locked lesson.
About this lesson
More advanced looping by looping while or until a certain condition is met.
Exercise files
Download this lesson’s exercise file.
Loops: Looping under conditions with Do While/Until loops.xlsm23.5 KB
Quick reference
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.
Instructions
Syntax: Do Loop Until
Do
<Action>
Loop Until <Condition>
Syntax: Do Until Loop
Do Until <Condition>
<Action>
Loop
Syntax: Do Loop While
Do
<Action>
Loop While <Condition>
Syntax: Do While Loop
Do While <Condition>
<Action>
Loop
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.