conditional formatting based on multiple criteria

Calvest1

New Member
Joined
Jul 24, 2024
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi Experts,

I have some data stored in a table (Data Table).

Data Table
DateStart TimeDurationEnd TimeTaskWorker
24/07/2024​
06:00​
120​
08:00​
Test descriptionWorker 1
25/07/2024​
07:00​
120​
09:00​
SleepWorker 2

I would like to apply conditional formatting based on Date, Start / end time and worker in the cells below (Range to colour) in the example data the x would be coloured.

Range to colour
24/07/2024​
06:00​
07:00​
08:00​
09:00​
10:00​
11:00​
12:00​
Worker 1XX
Worker 2XX

Please can you help with a formula for this?

Thank you in advance
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Are the X's in your sample part of the actual data or are you just using them to show what you want highlighted?
 
Upvote 0
Will the two lists always be in the same order by Worker? If not, how will they be sorted?

Will the duration always be a multiple of 60? If not, what increments could it be in?
 
Upvote 0
Will the two lists always be in the same order by Worker? If not, how will they be sorted?

Will the duration always be a multiple of 60? If not, what increments could it be in?
it will be sorted by worker, date, and time.

the duration could change to 15, 30, 45, 60 and up depending on how long is required.

Thanks
 
Upvote 0
Okay, this is what I have. If columns I:P are an accurate representation of your daily layout, then you will need a separate CF formula for each day.

Book1
ABCDEFGHIJKLMNOP
1DateStart TimeDurationEnd TimeTaskWorker24/07/202406:0007:0008:0009:0010:0011:0012:00
224/07/202406:0012008:00Test descriptionWorker 1Worker 1XX     
325/07/202407:0012009:00SleepWorker 2Worker 2       
4
525/07/202406:0007:0008:0009:0010:0011:0012:00
6Worker 1       
7Worker 2 XX    
Sheet1
Cell Formulas
RangeFormula
J2:P3J2=IF(AND(J$1>=FILTER($B$2:$B$3,($A$2:$A$3=$I$1)*($F$2:$F$3=$I2),""),K$1<=FILTER($D$2:$D$3,($A$2:$A$3=$I$1)*($F$2:$F$3=$I2),""),K$1<>""),"X","")
J6:P7J6=IF(AND(J$1>=FILTER($B$2:$B$3,($A$2:$A$3=$I$5)*($F$2:$F$3=$I6),""),K$1<=FILTER($D$2:$D$3,($A$2:$A$3=$I$5)*($F$2:$F$3=$I6),""),K$1<>""),"X","")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J6:P7Expression=IF(AND(J$1>=FILTER($B$2:$B$3,($A$2:$A$3=$I$5)*($F$2:$F$3=$I6),""),K$1<=FILTER($D$2:$D$3,($A$2:$A$3=$I$5)*($F$2:$F$3=$I6),""),K$1<>""),"X","")="X"textNO
J2:P3Expression=IF(AND(J$1>=FILTER($B$2:$B$3,($A$2:$A$3=$I$1)*($F$2:$F$3=$I2),""),K$1<=FILTER($D$2:$D$3,($A$2:$A$3=$I$1)*($F$2:$F$3=$I2),""),K$1<>""),"X","")="X"textNO
 
Upvote 0
You can ignore the cell formulas, those are not necessary. Those are there for me to work out the formula for the CF.

The CF formulas can even be shortened a little bit:

J2:P3
Excel Formula:
=AND(J$1>=FILTER($B$2:$B$3,($A$2:$A$3=$I$1)*($F$2:$F$3=$I2),""),K$1<=FILTER($D$2:$D$3,($A$2:$A$3=$I$1)*($F$2:$F$3=$I2),""),K$1<>"")

J6:P7
Excel Formula:
=AND(J$1>=FILTER($B$2:$B$3,($A$2:$A$3=$I$5)*($F$2:$F$3=$I6),""),K$1<=FILTER($D$2:$D$3,($A$2:$A$3=$I$5)*($F$2:$F$3=$I6),""),K$1<>"")
 
Upvote 0
Okay, this is what I have. If columns I:P are an accurate representation of your daily layout, then you will need a separate CF formula for each day.

Book1
ABCDEFGHIJKLMNOP
1DateStart TimeDurationEnd TimeTaskWorker24/07/202406:0007:0008:0009:0010:0011:0012:00
224/07/202406:0012008:00Test descriptionWorker 1Worker 1XX     
325/07/202407:0012009:00SleepWorker 2Worker 2       
4
525/07/202406:0007:0008:0009:0010:0011:0012:00
6Worker 1       
7Worker 2 XX    
Sheet1
Cell Formulas
RangeFormula
J2:P3J2=IF(AND(J$1>=FILTER($B$2:$B$3,($A$2:$A$3=$I$1)*($F$2:$F$3=$I2),""),K$1<=FILTER($D$2:$D$3,($A$2:$A$3=$I$1)*($F$2:$F$3=$I2),""),K$1<>""),"X","")
J6:P7J6=IF(AND(J$1>=FILTER($B$2:$B$3,($A$2:$A$3=$I$5)*($F$2:$F$3=$I6),""),K$1<=FILTER($D$2:$D$3,($A$2:$A$3=$I$5)*($F$2:$F$3=$I6),""),K$1<>""),"X","")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J6:P7Expression=IF(AND(J$1>=FILTER($B$2:$B$3,($A$2:$A$3=$I$5)*($F$2:$F$3=$I6),""),K$1<=FILTER($D$2:$D$3,($A$2:$A$3=$I$5)*($F$2:$F$3=$I6),""),K$1<>""),"X","")="X"textNO
J2:P3Expression=IF(AND(J$1>=FILTER($B$2:$B$3,($A$2:$A$3=$I$1)*($F$2:$F$3=$I2),""),K$1<=FILTER($D$2:$D$3,($A$2:$A$3=$I$1)*($F$2:$F$3=$I2),""),K$1<>""),"X","")="X"textNO
Hi Dreid1011,

This is fantastic, when i add a second entry for worker 1 (different time) - it turns all the entries for worker 1 blank rather than filling in the X at both time slots.

DateStart TimeDurationEnd TimeTaskWorker
24/07/2024​
06:00​
120​
08:00​
Test descriptionWorker 1
24/07/2024
10:00
60
11:00
Test Item 2Worker 1
24/07/2024​
07:00​
120​
09:00​
SleepWorker 2

Do you know why it would do that?

Thanks
 

Attachments

  • Screenshot 2024-07-25 171748.png
    Screenshot 2024-07-25 171748.png
    33.9 KB · Views: 2
  • Screenshot 2024-07-25 171846.png
    Screenshot 2024-07-25 171846.png
    34.7 KB · Views: 2
Upvote 0
Ah, I see. This complicates things. I suppose I could have figured there would be more than one entry per worker per day, even though your sample data did not show it. Alright, I will take a look and see if I can work it out.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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