Each time within the loop, it would display a message box with the value of the LCounter variable. It would loop 5 times, starting at 1 and ending at 5. In this example, the FOR loop is controlled by the LCounter variable.
This will allow you to repeat VBA code a fixed number of times. The simplest implementation of the FOR loop is to use the FOR.NEXT statement to create a single loop.
Let's look at how to create a FOR loop in Microsoft Excel, starting with a single loop, double loop, and triple loop, and then exploring how to change the value used to increment the counter each pass through the loop. The FOR.NEXT statement can only be used in VBA code in Microsoft Excel.