Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just another option in the immediate window (use of @)
For i = 2 To 3 Step 0.01@: Debug.Print i: Next i 'or Sub Demo() Dim i As Currency For i = 2 To 3 Step 0.01: Debug.Print i: Next i End Sub Dana "Tushar Mehta" wrote in message news:MPG.1b82ad57e64d231d9898b9@news-server... Tom's comment about precision loss in cells also applies to VBA. Try this simple test. In the Immediate Window type in for i=2.00 to 3.00 step 0.01:debug.Print i:next i Upto 2.23 everything is as expected. Then, instead of 2.24, I get 2.23999999999999. By contrast, the following gave accurate results from 2 to 3: For xStep=0 to (3-2)/0.01:x=2+xStep*0.01:debug.Print x:next xstep So, you may want to try: dim xStep as integer,x as double 'might need long rather than integer For xStep=0 to (gb-ga)/0.01 x=ga+xStep*0.01 ... next xStep Also, when you share code, it would help if you included the variable declaration statements. -- Regards, Tushar Mehta www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Office productivity solutions In article , Peer says... I have tried every datatype it could possibly be; integer, long, single, double, even variant after which I defined decimal numbers with cdec. It was the first solution (or error) I thought of. And the numbers are exactly the numbers I'm searching for, beause there are no formula's in the range, and the values are manual input. ![]() --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Decimal Numbers typed into Excel 2003 read as whole numbers | Excel Discussion (Misc queries) | |||
Subtracting two 2-decimal place numbers gives result 13-decimal places? | Excel Worksheet Functions | |||
If then statement displaying 2 or 3 decimal places | Excel Worksheet Functions | |||
How can I sort mostly 3 decimal with some 4 decimal numbers | Excel Discussion (Misc queries) | |||
If Statement - in time not decimal minutes | Excel Worksheet Functions |