Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Problem with 'For' loop execution [VBA,Excel XP]

http://www.cpearson.com/excel/rounding.htm

I expect you are getting accumulated rounding error.
--
Regards,
Tom Ogilvy

"Angelos Markos" wrote in message
m...
I'm a VBA begginer and i've recently faced the following problem:

Suppose we have the following sub:

Sub test()
Dim i
For i = 0.6 To 0.8 Step 0.01
MsgBox (i)
Next i
End Sub

Surprisingly, in the above loop the last value (0.8) does not appear.

On the contrary, in the following sub (step is 0.1 instead of 0.01)

Sub test2()
Dim i
For i = 0.6 To 0.8 Step 0.1
MsgBox (i)
Next i
End Sub

everything is ok.
How do you explain that?

--
With respect,
A.M.



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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop Problem John[_88_] Excel Programming 3 July 10th 04 10:55 AM
Excel 97 stuck in calculation loop - maximum cells problem? dl Excel Programming 1 June 25th 04 06:24 PM
Excel VBA - loop code problem ellis_x Excel Programming 4 June 23rd 04 11:22 PM
Dynamic execution of a loop Jeroen Kluytmans Excel Programming 1 February 23rd 04 04:09 PM
Excel VBA - Help with a loop, compare, delete problem rippy Excel Programming 0 February 4th 04 03:38 PM


All times are GMT +1. The time now is 08:25 AM.

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"