Conditional Format based on time difference

Diesel9a1

New Member
Joined
Feb 12, 2015
Messages
37
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Employee ID[/TD]
[TD]Name[/TD]
[TD]Start[/TD]
[TD]Finish[/TD]
[/TR]
[TR]
[TD]161[/TD]
[TD]Paul[/TD]
[TD]10/08/2019 23:00:00[/TD]
[TD]11/08/2019 06:00:00[/TD]
[/TR]
[TR]
[TD]100[/TD]
[TD]Fred[/TD]
[TD]10/08/2019 23:00:00[/TD]
[TD]11/08/2019 06:00:00[/TD]
[/TR]
[TR]
[TD]224[/TD]
[TD]Jane[/TD]
[TD]11/08/2019 10:00:00[/TD]
[TD]11/08/2019 18:00:00[/TD]
[/TR]
[TR]
[TD]100[/TD]
[TD]John[/TD]
[TD]11/08/2019 15:00:00[/TD]
[TD]12/08/2019 03:00:00[/TD]
[/TR]
[TR]
[TD]161[/TD]
[TD]Paul[/TD]
[TD]11/08/2019 16:00:00[/TD]
[TD]12/08/2019 02:00:00[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


Looking for excel to do an auto conditional format and highlight issues where the same employee starts their next shift within 12 hours of them finishing their previous shift. Easy if the table is sorted by name then start date, as it could simply minus the finish of previous shift from the start of current shift and if less than 12 hours, highlight in red. But the table is as is with regards the entry. There could be many employees in between the two entries of the same user (in our case Paul). Also need to cater for shifts going over midnight etc.

Any thoughts please?
 
Last edited:

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi, Below should work:

For Column C:

Code:
=IFERROR(AGGREGATE(14,6,--((($D$2:$D$6-C2)/((B2=$B$2:$B$6)*(ROW(B2)<>ROW($B$2:$B$6))))<0.5),1)>0,FALSE)

For Column D:
Code:
=IFERROR(AGGREGATE(14,6,--(((D2-$C$2:$C$6)/((B2=$B$2:$B$6)*(ROW(B2)<>ROW($B$2:$B$6))))<0.5),1)>0,FALSE)


Book1
ABCD
1Employee IDNameStartFinish
2161Paul10/8/19 11:00 PM11/8/19 6:00 AM
3100Fred10/8/19 11:00 PM11/8/19 6:00 AM
4224Jane11/8/19 10:00 AM11/8/19 6:00 PM
5100John11/8/19 3:00 PM12/8/19 3:00 AM
6161Paul11/8/19 4:00 PM12/8/19 2:00 AM
Sheet3


Screenshots:

https://drive.google.com/open?id=1QvtnigmDgZYGyS8QUQtNHirxAMSY3YBY

https://drive.google.com/open?id=1aAKTJm7d-ptmM5O-BEZF8g23vYexGdRN

https://drive.google.com/open?id=10Nb8tw1p3VvRvhqwm4eEiTtFyZPN_QnJ

https://drive.google.com/open?id=1nEtPXMqT1GqTVu8SkiW9v8dBuw8MjTWX

https://drive.google.com/open?id=1CehJptuwHjLlHO075F_p_l20vGkNuXuN
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,144
Members
453,021
Latest member
Justyna P

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