If cell matches another cell, apply conditional formatting to another cell

SuperX7

New Member
Joined
Dec 29, 2017
Messages
13
Hi everyone...

This one's stumped me. I'm trying to create a staff roster where employees are selected from a drop down list.

The issue is that there could be instances where the same employee (in this case Employee 1) is working in a different location so may be listed elsewhere.

Is it possible, to conditional format the start and finish times IF the employee is listed elsewhere AND if the times fall within the same time window to avoid "double booking" or incorrect scheduling?

For example below I've managed to conditional format

B58:
=AND(B58>B48,B58<C48) - 1200 is after 1000 and before 1800

C58:
=(C58<C48) - 1700 is before 1800

Which indicates the schedule isn't possible as the times fall within ROW 48 with the same employee

This may be a long shot but I have to ask the experts here as its driving me nuts!


Screenshot 2024-11-08 at 01.11.28.png
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
How about:

Book1
ABC
1NameStartEnd
2Employee 110:0018:00
3
4Employee 28:0010:00
5
6Employee 38:0010:00
7
8Employee 312:0014:00
9
10Employee 39:3011:00
11
12Employee 112:0017:00
13
14
15
16
17
18
19
20
Sheet10
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:C20Expression=SUM(($A$2:$A$20=$A2)*(ROW($A$2:$A$20)<>ROW(A2))*(IF($C$2:$C$20<$C2,$C$2:$C$20,$C2)-IF($B$2:$B$20>$B2,$B$2:$B$20,$B2)>0))textNO
 
Upvote 0
How about:

Book1
ABC
1NameStartEnd
2Employee 110:0018:00
3
4Employee 28:0010:00
5
6Employee 38:0010:00
7
8Employee 312:0014:00
9
10Employee 39:3011:00
11
12Employee 112:0017:00
13
14
15
16
17
18
19
20
Sheet10
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:C20Expression=SUM(($A$2:$A$20=$A2)*(ROW($A$2:$A$20)<>ROW(A2))*(IF($C$2:$C$20<$C2,$C$2:$C$20,$C2)-IF($B$2:$B$20>$B2,$B$2:$B$20,$B2)>0))textNO
Hi Eric,

This is amazing, thank you... one thing I did notice is that if I put a time outside midnight it won't highlight?

eg.
EMP1
Start - 1000
End - 2100

EMP2
Start - 2000
End - 0200

They should in theory highlight?
 
Upvote 0
Well, not necessarily. First, those 2 won't highlight because they are different employees. But even if those were the same employee, they wouldn't highlight. The issue is that the formula does not know that the 0200 time is for the next day. One way to handle this is to enter the date as part of the time:

Book1
ABC
1NameStartEnd
2Employee 111/19/24 10:0011/19/24 21:00
3
4Employee 211/19/24 8:0011/19/24 10:00
5
6Employee 311/19/24 8:0011/19/24 10:00
7
8Employee 311/19/24 12:0011/19/24 14:00
9
10Employee 311/19/24 9:3011/19/24 11:00
11
12Employee 111/19/24 20:0011/20/24 2:00
Sheet2


I'm not sure what this does to your entry methodology, but it is clear. The other option is to change the formula so that if the time in the end column is less than the time in the start column, we assume that it's the next day:

Book1
ABC
1NameStartEnd
2Employee 110:0021:00
3
4Employee 28:0010:00
5
6Employee 38:0010:00
7
8Employee 312:0014:00
9
10Employee 39:3011:00
11
12Employee 120:002:00
13
14
15
16
17
18
19
20
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:C20Expression=SUM(($A$2:$A$20=$A2)*(ROW($A$2:$A$20)<>ROW(A2))*(IF($C$2:$C$20+($C$2:$C$20<$B$2:$B$20)<$C2+($C2<$B2),$C$2:$C$20+($C$2:$C$20<$B$2:$B$20),$C2+($C2<$B2))-IF($B$2:$B$20>$B2,$B$2:$B$20,$B2)>0))textNO


A bit more complicated but viable. Also, please update your profile to show the version of Excel you're using. I could have made this a bit shorter if you're using a newer version, but I didn't want to assume.
 
Upvote 0
Hi Eric!

Thanks - my apologies my response contained a typo regarding the EMP numbers (they were both supposed to be the same person). I'll give the 2nd solution you've provided a go and report back!
 
Upvote 0

Forum statistics

Threads
1,224,803
Messages
6,181,055
Members
453,014
Latest member
Chris258

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