#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default help me...

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default help me...

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

"Young-Hwan Choi" wrote in message
...
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default help me...

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 *

"Young-Hwan Choi" wrote in message
...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"