help me...

  • Thread starter Thread starter Young-Hwan Choi
  • Start date Start date
Y

Young-Hwan Choi

When I run the code below, it writes 0, 0.1, and 0.2. It doesn't write the
last one, 0.3.
If I change 0.3 to 0.6, it writes 0 to 0.5, not 0.6.
What's wrong with it?
(I recall someone said about dim, or something regarding this... but, I
don't know ...)

Sub test()
For i = 0 To 0.3 Step 0.1
ActiveCell.Offset(1, 0).Activate
ActiveCell = i
Next i
End Sub

thanks
 
try these. Easiest to just increase your .3 to .4,
However, the 2nd will be faster due to no selections.

--sub test()
For i = 0 To 0.4 Step 0.1
ActiveCell.Offset(1, 0).Activate
ActiveCell = i
Next i
End Sub

Sub testD() 'Start with 0 in the active cell.
x = ActiveCell.Row
For i = x To x + 2 Step 1
Cells(i + 1, 1).Value = Cells(i, 1) + 0.1
Next i
End Sub


Don Guillett
SalesAid Software
(e-mail address removed)
 
I don't know what exactly is wrong with it, but i suppose that where 0,1 is
added actually you don't reach 0,3 (or 0,6) but something like o,300000001
and thus > 0,3

Problem can be solved by changing the code to

Sub test()
For i = 0 To 3 Step 1
ActiveCell.Offset(1, 0).Activate
ActiveCell = i /10
Next i
End Sub


--
Regards,
Auk Ales

* Please reply to this newsgroup only *
* I will not react on unsolicited e-mails *
 
That gave me an idea. Use this for no selections. WORKS!

Sub testdFINAL()
For i = 0 To 3 Step 1
ActiveCell.Offset(i, 0) = i / 10
Next i
End Sub
 
Back
Top