From Macros Wiki
- FOR <loop variable> = <start> TO <end> [STEP <step value>]
- The FOR command is used in conjunction with the NEXT command and is used to define a block of macro commands that are executed several times. You define a loop variable and an initial value for that variable. All of the macro commands following the FOR command and up to the matching NEXT command will be executed. When the NEXT command is reached, the loop variable will be adjusted by adding a step amount. The new value of the loop variable is compared with the end value for the loop and if the end value has not yet been reached, the macro will go back to the first line after the FOR command and start processing again.
- <loop variable>
- A number variable.
- Start value. The loop variable will initially be set to this start value
- used to separate the start and end values
- End value. The loop will be repeated until the loop variable reaches this end value.
- used to indicate that a step value other than 1 is to be used.
- Step. Each time the loop is executed, the loop variable will modified by adding this step value.
- FOR I = 1 TO 3
- FOR J = 2 TO 8 STEP 2
- The first loop will execute 3 times, with I set to 1, 2 and 3.
- The second loop will execute 4 times with J set to 2, 4, 6 and 8.