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

#### ms1202

##### New Member
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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

#### ms1202

##### New Member
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.

Replies
4
Views
692
Replies
2
Views
337
Replies
2
Views
135
Replies
5
Views
140
Replies
3
Views
168

1,141,757
Messages
5,708,340
Members
421,566
Latest member
7Nabisco

### 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.

### Which adblocker are you using?

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

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