CF Rule: Highlight Range using Multiple Criteria

zero269

Active Member
Joined
Jan 16, 2023
Messages
253
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm currently using the following CF Rule to highlight cells in two columns that meet a single criteria from a list on another sheet.

Excel Formula:
=SUM(COUNTIF(C2,"*"&INDIRECT("t_Whitelist[Author-Series]")&"*"))

However, I would like to expand my criteria to only highlight the cells that meet the current criteria AND one more.

For example, instead of updating a single list with preferred Author's and Series, I added a Status column that will use "active" as the second criteria. This way I can make changes to the Whitelist without having to remove them, only to add them back as needed.

In other words, if Status = "active", AND my current criteria, then highlight cell.

I've tried replacing COUNTIF with COUNTIFS but get a VALUE error.

VBA Testing.xlsm
ABCDEFGH
1QuizTitleAuthorSeriesAuthor-SeriesRangeStatus
2149101All You Ever NeedLucado, MaxAbdo, KennyAuthoractive
388934Aloha, Scooby-Doo!Weyn, SuzanneScooby-Doo (Scholastic);AesopSeries
4192174Ant and the GrasshopperWindmill Book EditorsLet's Learn Aesop's Fables;All Aboard AmericaSeriesactive
59004Bear DetectivesBerenstain, StanBerenstain Bears;Amazing ScienceSeriesactive
6507949Black PanthersAbdo, KennySuperhero Animals;Berenstain BearsSeries
759946Gateway ArchMurray, JulieAll Aboard America;Lucado, MaxAuthoractive
8103786Tires, Spokes, and SprocketsDahl, MichaelAmazing Science: Simple Machines;Scooby-DooSeries
CF_Range
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C2:D8Expression=SUM(COUNTIF(C2,"*"&INDIRECT("t_Whitelist[Author-Series]")&"*"))textNO


Any help would be greatly appreciated.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I think you just need to put an AND function and test the cells in H2.
Excel Formula:
=AND(
SUM(COUNTIF(C2,"*"&INDIRECT("t_Whitelist[Author-Series]")&"*")),
H2="active"
)
(if the case can change, you may want to be doubly sure you're matching, and maybe use UPPER(H2)="ACTIVE"
 
Upvote 0
How about
Excel Formula:
=SUM(COUNTIF(C2,"*"&FILTER(INDIRECT("t_Whitelist[Author-Series]"),INDIRECT("t_whitelist[Status]")="active")&"*"))
 
Upvote 0
Solution
I think you just need to put an AND function and test the cells in H2.
Excel Formula:
=AND(
SUM(COUNTIF(C2,"*"&INDIRECT("t_Whitelist[Author-Series]")&"*")),
H2="active"
)
(if the case can change, you may want to be doubly sure you're matching, and maybe use UPPER(H2)="ACTIVE"
Hello awoohaw,

Sorry for the late reply. I tested your code, but unfortunately it's only highlighting one cell out of the four that are active. Here's what it looks like:

VBA Testing.xlsm
ABCDEFG
1QuizTitleAuthorSeriesAuthor-SeriesStatus
2149101All You Ever NeedLucado, MaxAbdo, Kennyactive
388934Aloha, Scooby-Doo!Weyn, SuzanneScooby-Doo (Scholastic);Aesop
4192174Ant and the GrasshopperWindmill Book EditorsLet's Learn Aesop's Fables;All Aboard Americaactive
59004Bear DetectivesBerenstain, StanBerenstain Bears;Amazing Scienceactive
6507949Black PanthersAbdo, KennySuperhero Animals;Berenstain Bears
759946Gateway ArchMurray, JulieAll Aboard America;Lucado, Maxactive
8103786Tires, Spokes, and SprocketsDahl, MichaelAmazing Science: Simple Machines;Scooby-Doo
9t_Bookst_Whitelist
CF_Range
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C2:C8Expression=AND( SUM(COUNTIF(C2,"*"&INDIRECT("t_Whitelist[Author-Series]")&"*")), G2="active" )textNO

One thing I learned after playing around with some changes to your code is that AND & INDIRECT don't really play well together.
Unfortunately, everything I tried would result in unexpected results. For this reason I decided to switch back to using Named Ranges for my Table references.

Thank you…
 
Upvote 0
How about
Excel Formula:
=SUM(COUNTIF(C2,"*"&FILTER(INDIRECT("t_Whitelist[Author-Series]"),INDIRECT("t_whitelist[Status]")="active")&"*"))
Hello Fluff,

Thanks for helping me out again. Your code works perfectly.

Due to the amount of time I spent yesterday working on a solution, I discovered that the INDIRECT function - as much as I like it - has some flaws as it relates to performance.

I decided to switch back to using Named Ranges for my large datasets which is where your formula will be used. So, the only changes I had to make was converting the Table references to Named Ranges.

Excel Formula:
=SUM(COUNTIF(C2,"*"&FILTER(l_AuthorSeries,l_WhitelistStatus="active")&"*"))

VBA Testing.xlsm
ABCDEFG
1QuizTitleAuthorSeriesAuthor-SeriesStatus
2149101All You Ever NeedLucado, MaxAbdo, Kennyactive
388934Aloha, Scooby-Doo!Weyn, SuzanneScooby-Doo (Scholastic);Aesop
4192174Ant and the GrasshopperWindmill Book EditorsLet's Learn Aesop's Fables;All Aboard Americaactive
59004Bear DetectivesBerenstain, StanBerenstain Bears;Amazing Scienceactive
6507949Black PanthersAbdo, KennySuperhero Animals;Berenstain Bears
759946Gateway ArchMurray, JulieAll Aboard America;Lucado, Maxactive
8103786Tires, Spokes, and SprocketsDahl, MichaelAmazing Science: Simple Machines;Scooby-Doo
9t_Bookst_Whitelist
CF_Range
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C2:D8Expression=SUM(COUNTIF(C2,"*"&FILTER(l_AuthorSeries,l_WhitelistStatus="active")&"*"))textNO

Thanks again Fluff, and best regards. This was very helpful and means I don't have to use a separate - single column - list for the Whitelist.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,117
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