Looping

You can use loop structures to repeatedly run a section of your macro. Visual Basic loop structures include the following statements.

To

Use

Test a condition at the start of the loop, run the loop only if the condition is True, and continue until the condition becomes False

Do While...Loop

Test a condition at the start of the loop, run the loop only if the condition is False, and continue until the condition becomes True

Do Until...Loop

Always run the loop once, test a condition at the end of the loop, continue while the condition is True, and stop when the condition becomes False

Do...Loop While

Always run the loop once, test a condition at the end of the loop, continue while the condition is False, and stop when the condition becomes True

Do...Loop Until

Run a loop a set number of times, using a loop counter that starts and ends at specified values and that changes value by a specified amount each time through the loop

For...Next

Run a loop once for each object in a collection

For Each...Next