The following code is easy and outputs as expected
CODE:
Option Explicit
Sub Test_loop2()
Dim i As Long
For i = -3 To 3 Step 1
Debug.Print i
Next i
End Sub
OUTPUT:
The following code is exiting early due to rounding
Option Explicit
Sub Test_loop2()
Dim i As Double
For i = -0.3 To 0.3 Step 0.1
Debug.Print i
Next i
End Sub
OUTPUT:
What is the most reliable method I can use whilst retaining a For Loop
to ensure the last value is run in the loop for non integers?
Eg For i = X to Y step Z - Y must always be reached if it's multiple of Z
For i = 0 to 0.3 step 0.1 then 0.3 will be in loop
For i = 0 to 0.3 step 0.2 then 0.3 will NOT be in the loop