When is 23:01 < 23:00?!?

ms1202

New Member
Joined
May 25, 2006
Messages
26
Part of my macro uses the following if statement. It works fine until Cells(1,z) = Cells(y,6) when it insists on evaluating the if statement as true. Cells(y,5) and Cells(y,6) represent the start and end of shifts and Cells(z,1) run from 00:00:00 to 23:00:00 hourly. The idea is that eventually I can sum down the columns to get the amount of time worked during that hour period in total.

Code:
            For z = 10 To 33
                If (((Cells(y, 5) < Cells(y, 6)) 
                 And (Cells(1, z) + 6.94444444444444E-04 >= Cells(y, 5) 
                 And Cells(1, z) + 6.94444444444444E-04 < Cells(y, 6))) 
                 Or ((Cells(y, 5) > Cells(y, 6)) 
                 And (Cells(1, z) + 6.94444444444444E-04 >= Cells(y, 6) 
                 Or Cells(1, z) + 6.9444444444444E-04 < Cells(y, 5)))) Then
                     Cells(y, z) = 4.16666666666667E-02
                End If
            Next z
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I tried adding 10mins on instead of just one and it worked. Still don't understand why 23:01 didn't work as less than 23:00 though.
 
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,915
Members
448,532
Latest member
9Kimo3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top