LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default VBA Time comparison not correct

This is terrible programming but it works.

Dim n As Integer
For n = 1 To 1440
'check if column 1 value is later than H1
If Round(Cells(n, 1).Value, 10) = Cells(1, 8) Then
'check if column 1 value is before I1
If Cells(n, 1) <= Round(Cells(1, 9).Value, 10) Then
Cells(n, 2) = 1
End If
End If
Next n


rounding any repeating values drops any repetition after the round point and
forces the number to be less than what I am comparing it to. Rounding both
to the same value doesn't seem to work. I am really surprised this behavior
hasn't caused anyone else any problems.


(Earlier I had changed all values to numbers 0-59,100-159,200-259,300-359...
This worked beautifully as far as the =, <= comparisons were concerned but
took about 5 seconds to loop as compared to less than a second with time
values.)
 
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
Subtract hours from a time and get the correct time casey Excel Worksheet Functions 1 June 22nd 08 08:41 PM
Time comparison problem Ray Batig Excel Programming 3 May 7th 07 12:01 AM
Time Comparison Charles in Iraq Excel Programming 1 October 14th 06 11:40 AM
Time comparison formula montagu Excel Discussion (Misc queries) 3 August 25th 05 03:37 PM
Time comparison Gixxer_J_97[_2_] Excel Programming 1 July 22nd 05 04:45 PM


All times are GMT +1. The time now is 02:07 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"