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

I have a worksheet with a column of time values (column A). I entered the
first 3 manually

00:00
00:01
00:02
and then autofilled down to 23:59


I have another cell(c3) formatted the same as column A which I placed
another time value into 19:00.

In VBA I am comparing the time in C3 and with each of the values in column A
and if the times are the same I am placing a 1 in column B next to the same
time.

For n = 1 To 1440
If Cells(n, 1) = Cells(3, 3) Then
Cells(n, 2) = 1
End If
Next n

This is an oversimplification of a much more complex project but it
demonstrates the error exactly. The problem is that there are certain values
that do not seem to match even though they should. For example when I run
this with the value of 19:00 in C3 column b has no values even though B1141
should = 1.


 
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 08:42 PM.

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

About Us

"It's about Microsoft Excel"