Conditional Formatting based on specific text in a column and it's related values in another column

mizzoh

New Member
Joined
Aug 29, 2022
Messages
7
Office Version
  1. 2021
Platform
  1. Windows
Let's say I have a dropdown with two options (A2):
Category 1
Category 2

I also have a range of cells given with different phrases: (A4:C5)

Phrase A
Phrase B
Phrase C
Phrase DPhrase EPhrase F

and also a table which looks like this: (A6:B12)

PhraseCategory
Phrase ACategory 1
Phrase B
Category 1
Phrase CCategory 2
Phrase DCategory 1
Phrase ECategory 2
Phrase FCategory 2

What I want to do is to highlight my range of cells (A4:C5) based on the Dropdown value which I selected.

So, if I select Category 1 in the Dropdown the cells Phrase A, Phrase B and Phrase D should be highlighted with another color in my range of cells (A4:C5) not in the table itself.

Could you please explain how I can achieve this goal?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
try
=COUNTIFS($A$7:$A$12,A4,$B$7:$B$12,$A$2)

for 2007, 2010 , 2013 , 2016 , 2019 or 365 Subscription excel version
Conditional Formatting

Highlight applicable range >>
A4:C5 - Change, reduce or extend the rows to meet your data range of rows

Home Tab >> Styles >> Conditional Formatting
New Rule >> Use a formula to determine which cells to format
Edit the Rule Description: Format values where this formula is true:

=COUNTIFS($A$7:$A$12,A4,$B$7:$B$12,$A$2)

Format [Number, Font, Border, Fill]
choose the format you would like to apply when the condition is true
OK >> OK

Book4
ABCDEFGHI
1
2category 1
3
4Phrase APhrase BPhrase C110category 1
5Phrase DPhrase EPhrase F100category 2
6PhraseCategory
7Phrase ACategory 1
8Phrase BCategory 1
9Phrase CCategory 2
10Phrase DCategory 1
11Phrase ECategory 2
12Phrase FCategory 2
Sheet1
Cell Formulas
RangeFormula
E4:G5E4=COUNTIFS($A$7:$A$12,A4,$B$7:$B$12,$A$2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A4:C5Expression=COUNTIFS($A$7:$A$12,A4,$B$7:$B$12,$A$2)textNO
Cells with Data Validation
CellAllowCriteria
A2List=$I$4:$I$5


will only be on the dropbox link for a few days
 
Upvote 0
Solution
Thanks for your response. It works, however, I just don't understand why the criteria for the first Countifs- condition is only A4 and not the cell range of the phrases in a "OR" manner.
 
Upvote 0
because conditional formatting changes the cell reference itself

So as you have selected A4 to C5 to conditional format
then it starts by k=looking at A4 as per the formula (which is why its important to get the formula cell reference correct)
=COUNTIFS($A$7:$A$12,A4,$B$7:$B$12,$A$2)

Now all the other cells are fixed with $
so then it moves to B4 and checks - effectively
=COUNTIFS($A$7:$A$12,B4,$B$7:$B$12,$A$2)
then
=COUNTIFS($A$7:$A$12,C4,$B$7:$B$12,$A$2)
then
=COUNTIFS($A$7:$A$12,A5,$B$7:$B$12,$A$2)
etc

so you only need to specify the 1st formula and conditional formatting will do the rest
Hence why its important to have the correct cell values in a formula compared to the area you select to apply the conditional formatting too

hope that makes sense
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
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