Time difference with conditional formatting

Smarahj

New Member
Joined
Mar 5, 2024
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello!

I need help with a formula. I need to highlight in red a cell that has an hour time difference. Start time for a driver is 03:00. They are out of hours at 17:00. The estimated completion time for their route is 1900. I need the cell to highlight as red if it is within 1 hour of 1700. I have not been able to find anything that matches what I'm looking for. Help!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Welcome to the forum.

Maybe something like this.
-Conditional Formatting
-New Rule
-Use a formula
For formula enter (change time range to match your data)
=AND(A2>=16/24,A2<=18/24)

Book1
A
1Time
215:00
316:05
419:00
518:30
617:56
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A6Expression=AND(A2>=16/24,A2<=18/24)textNO
 
Upvote 0
Maybe it's because I'm looking at this super early but it's just not clicking with me. These are the columns in my spreadsheet. I need the HOS column to have the conditional formatting if the estimated completion time is within 1 hour of HOS.
1709713688134.png
 
Upvote 0
Try:
-Conditional Formatting
-New Rule
-Use a formula
For formula enter (change time range to match your data)
=(IF(B2<A2,A2-B2,B2-A2)*1440)<=60

Book1
AB
1HOSEst. Comp.
217:3518:19
317:0116:31
415:4917:29
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A4Expression=(IF(B2<A2,A2-B2,B2-A2)*1440)<=60textNO
 
Upvote 0
That worked.. somewhat. It turned every cell red, even those that had plenty of hours remaining.
1709802979963.png

This was the formula used, as adjusted for the correct cell number
=(IF($P$6<$O$6, $O$6-$P$6,$P$6-$O$$A$3:$P$816)*1550)<=60

Do I need to put in the time for each cell in the formula or can I apply the formula to the whole column?
 

Attachments

  • 1709802891569.png
    1709802891569.png
    20.5 KB · Views: 5
Upvote 0
Is this what you want? If not which cells should be red and why.
For this example I chose cells M4 to M17.
Formula I used:
=IF(M4="","",(IF(N4<M4,M4-N4,N4-M4)*1440)<=60)

Book1
HIJKLMN
1
2DelaytrneTotal StopsRemainir&Completed StoeActual Start TireHOSEstmated Completiore
3*
415153:5917:5917:34
516164:1618:1618:40
615151:5015:5016:11
7191912:082:0816:16
8992:0616:0616:16
912124:1718:1715:16
1016163:1017:1016:58
1112124:0418:0416:15
1217174:3118:3119:07
1317174:2118:2115:59
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
M4:M17Expression=IF(M4="","",(IF(N4<M4,M4-N4,N4-M4)*1440)<=60)textNO


1709850857038.png
 
Upvote 0
Is this what you want? If not which cells should be red and why.
For this example I chose cells M4 to M17.
Formula I used:
=IF(M4="","",(IF(N4<M4,M4-N4,N4-M4)*1440)<=60)

Book1
HIJKLMN
1
2DelaytrneTotal StopsRemainir&Completed StoeActual Start TireHOSEstmated Completiore
3*
415153:5917:5917:34
516164:1618:1618:40
615151:5015:5016:11
7191912:082:0816:16
8992:0616:0616:16
912124:1718:1715:16
1016163:1017:1016:58
1112124:0418:0416:15
1217174:3118:3119:07
1317174:2118:2115:59
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
M4:M17Expression=IF(M4="","",(IF(N4<M4,M4-N4,N4-M4)*1440)<=60)textNO


View attachment 108055
That is what I was looking for! I'll give a try. Thank you!
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,317
Members
452,905
Latest member
deadwings

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