Info

Let's take a close look at what happens as VBA gets to the line that says Next I. Before running this line, the variable I is equal to 1. During the execution of Next I, VBA must make a decision. VBA adds 1 to the variable I and compares it to the maximum value in the To clause of the For statement. If it is within the limits specified in the To clause, then the loop is not finished. In this case, the value of I will be incremented to 2. Code execution then moves back to the first line of code after the For statement. Figure 5.2 shows the state of the program before running the Next line. Figure 5.3 shows what happens after executing the Next line.

Figure 5.2

Before running the Next I statement, I is equal to 1.VBA can safely add 1 to I and it will be less than the 10 specified in the To clause of the For statement.

|l&enei.ilt

-r | |ciiap4«r5j

0 0

Post a comment