Excel – Conditional Formatting if one time is greater than the other

conditional formattingmicrosoft excel

I'm attempting to get excel to conditionally format a cell based on if it is 5 minutes greater than the value in the column next to it. It's to compare times to see if a person was late to work, we accept a 5 minute variance. If they are late, I want to format that cell showing the clock in time with pink fill and red bold letters. Below is a picture of the two columns though they are jumbled a bit.

http://i.stack.imgur.com/IlrgR.jpg )

Best Answer

Use the following formula in the conditional formatting for Actual Arrival Time column cells

=IF(HOUR(C3)=HOUR(B3),IF(MINUTE(C3)-MINUTE(B3)>5,TRUE,FALSE),IF(HOUR(C3)>HOUR(B3),TRUE,FALSE))

where column C has actual times and column B schedules times

To set this up go to HOME > Conditional Formatting > New Rule > Select "Use a formula to determine which cells to format" > enter the formula provide above and use the "Format" button to specify the highlighting that you'd like

Per further specifications noted below, use the following formula as an ADDITIONAL CONDITIONAL RULE to highlight (specify a different format) arrivals more than 5 mins early

=IF(HOUR(C3)=HOUR(B3),IF(MINUTE(B3)-MINUTE(C3)>5,TRUE,FALSE),IF(HOUR(C3)-HOUR(B3)=-1,IF(MINUTE(C3)-60,TRUE,FALSE),FALSE))

Related Question