Loops
Loops
VBA - Loops
There may be a situation when you need to execute a block of code several number of
times. In general, statements are executed sequentially: The first statement in a function
is executed first, followed by the second, and so on.
Programming languages provide various control structures that allow for more complicated
execution paths.
VBA provides the following types of loops to handle looping requirements. Click the
following links to check their detail.
for loop
1 Executes a sequence of statements multiple times and abbreviates the code
that manages the loop variable.
while..wend loop
3
This tests the condition before executing the loop body.
https://www.tutorialspoint.com/vba/vba_loops.htm 1/2
9/27/24, 1:45 AM VBA - Loops
do..while loops
4 The do..While statements will be executed as long as the condition is True.
(i.e.,) The Loop should be repeated till the condition is False.
do..until loops
5 The do..Until statements will be executed as long as the condition is False.
(i.e.,) The Loop should be repeated till the condition is True.
VBA supports the following control statements. Click the following links to check their
detail.
Exit Do statement
2 Terminates the Do While statement and transfers the execution to the
statement immediately following the loop
Explore our latest online courses and learn new skills at your own pace. Enroll and
become a certified expert to boost your career.
https://www.tutorialspoint.com/vba/vba_loops.htm 2/2