View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default for loop with step increment of 0.1

I'd guess that there was an internal rounding problem that you got hit with.

I'd use:

Sub test()
Dim i As Long
For i = 15 To 20 Step 1
Debug.Print i / 10
Next i
End Sub



choi4u wrote:

Running this code
Sub test()
For i = 1.5 To 2 Step 0.1
Debug.Print i
Next i
End Sub

gives this output
1.5
1.6
1.7
1.8
1.9 .

Why does the output not include 2.0?
and what do I have to do to make the output include 2.0?

Thanks in advance.


--

Dave Peterson