Loop Statements
VBA's loop statements are used to execute a block of statements a certain number of times. The For...Next and For Each...Next loops specify in advance the number of times the statements will be executed. The Do...Loop statement executes statements repeatedly until a specified logical condition is met.
For...Next
The For...Next statement executes a block of VBA statements a specified number of times. The syntax is:
For counter = start To stop Step step ... statements ... Next counter
Counter is a numeric variable used as the loop counter. Start and stop are the starting and ending values of counter. Step is a numerical expression that specifies the increment for counter. The Step step part of the statement is optional; if omitted, ...
Get Office® XP Development with VBA now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.