ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help me... (https://www.excelbanter.com/excel-programming/285820-help-me.html)

Young-Hwan Choi

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



Don Guillett[_4_]

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





A.W.J. Ales

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





Don Guillett[_4_]

help me...
 
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

--
Don Guillett
SalesAid Software

"A.W.J. Ales" wrote in message
...
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








All times are GMT +1. The time now is 11:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com