RAJAQ
12/1/2016 - 5:19 PM

For-Next examples with a Step > This time, Cnt starts out as 1 and then takes on values of 3, 5, 7, and so on. The Step value determines how

For-Next examples with a Step > This time, Cnt starts out as 1 and then takes on values of 3, 5, 7, and so on. The Step value determines how the counter is incremented. Notice that the upper loop value (1000) is not actually used because the highest value of Cnt will be 999.

Option Explicit
Dim Total As Double
Dim Cnt As Double


Sub AddNumbers()
    
    Total = 0
    For Cnt = 1 To 1000 Step 2
        Total = Total + Cnt
    Next Cnt

    MsgBox Total

End Sub