Conditional Formatting using date range and additional cell value

Wez

New Member
Joined
Jul 24, 2011
Messages
4
Greetings from Down Under,

Long time reader, first time poster.

I am trying to create a conditional format that highlights a range of cells based on a date range and the letter value in another cell. I need the cells to shade a certain colour depending on the letter value of the other cell

I have managed to conditionally format the cells based on date using

=IF((G27<$F$27)*(G27>$E$27), TRUE, FALSE

Where
E27 = First date of range
F27 = last date of range
G27 to Z27 = cells containing calendar dates to be highlighted

but cannot get the cells to change colour based on an additional letter value. Not sure if I can have an AND statement attached to the above

I need it to basically perform the following:

If B27 equals "XX" AND =IF((G27<$F$27)*(G27>$E$27), TRUE, FALSE then highlight the date cells red.

If B27 equals "YY" AND =IF((G27<$F$27)*(G27>$E$27), TRUE, FALSE then highlight the date cells blue.

Etc.

I realise that each letter value for B27 may require a new conditional format.

I have tried a number of options but cannot get it to work.

I hope that makes sense.

Can anyone help?

Regards

Wez
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hello, and welcome to the forum!
I'm by no means a conditional formatting expert, but the following formula seems to work:
Code:
=--(G1>$E$1)*--(G1<$F$1)*--(OR($B$1="XX",$B$1="YY"))
Additional optional conditions can be appended to the OR part of the function using the same structure as the "YY" part.
The "--" parts convert each section from TRUE/FALSE to 1/0 respectively, so that the multiplication doesn't blow up.

Hope that helps,
Cindy
 
Upvote 0
Thanks Cindy, works great,

I have applied it as such:

as two separate conditions

=(G28>$E$28)*(G28<$F$28)*(OR($B$28="XX")) .... format Green
=(G28>$E$28)*(G28<$F$28)*(OR($B$28="YY")) .... format Red

Now is there a way to apply it to multiple rows? Or do I need to have the the conditions set for each row?
 
Upvote 0
If you remove the $ before the "27" for all parts that are row dependent, you can then copy row 27, and use "Paste Special - Formats" to copy to additional rows. Be sure to leave the $ in front of any parts that should be anchored regardless of the data row.
If that's not clear, please post back and I'll try to explain it a different way. I've written it 3 ways so far, and none of them are crystal clear, not knowing if everything in the formula is row-dependent, or only parts of it.
Cindy
 
Upvote 0
Thanks Cindy, works great,

I have applied it as such:

as two separate conditions

=(G28>$E$28)*(G28<$F$28)*(OR($B$28="XX")) .... format Green
=(G28>$E$28)*(G28<$F$28)*(OR($B$28="YY")) .... format Red

Now is there a way to apply it to multiple rows? Or do I need to have the the conditions set for each row?
You don't need the OR function.

Use AND like this:

=AND(G28>$E$28,G28<$F$28,$B$28="XX")

=AND(G28>$E$28,G28<$F$28,$B$28="YY")
 
Upvote 0

Forum statistics

Threads
1,224,605
Messages
6,179,860
Members
452,948
Latest member
UsmanAli786

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