VBA Loop and types

VBA Loop allow user to repeat the same code block multiple times until a given condition or criteria is met.
A loop is simply a way of running the same lines of code a number of times
A loop statement allows us to execute a statement or group of statements multiple times.

VBA provides the following types of loops to handle looping requirements.


For loop

for loop is a repetition control structure that allows a developer to efficiently write a loop that needs to be executed a specific number of times.

Do Until Loop

A Do…Until loop is used when we want to repeat a set of statements as long as the condition is false. The condition may be checked at the beginning of the loop or at the end of loop.

Do While Loop

Do…While loop is used when we want to repeat a set of statements as long as the condition is true. The condition may be checked at the beginning of the loop or at the end of the loop.

For Each loop

For Each Loops loop through every object in a collection, such as every worksheet in workbook or every cell in a range.

Scroll to Top