Conditional Format - COUNTIF Range to a Criteria Range

Vesp

New Member
Joined
Aug 22, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi MrExcel, I have been scouring the board this morning and cant seem to find a solution to what I need.

I have a large data worksheet, reference worksheet and a search sheet i am using to lookup data.

The lookup sheet has a drop down tab of all people. based on your selection Column E3:E100 populate with all Model numbers of various products they own.

Cells B5:B9 has a list of every type of product required for the person selected, this list changes product types using an INDEX and Match function.

My reference sheet identifies what model numbers belong to what product type in separate columns. So Product Type 1 model numbers will always be in Reference!B2:B25, Product Type 2 will always be in Reference!C2:C25, ect

I want to conditionally format B5:B9 to check if the product types they require is on the list of their owned products.

to do this i have done the following =IF(COUNTIF(B5:B9,"Product Type 1"),IF(COUNTIF(E2:E100,Reference!B25),TRUE,FALSE))
However this will only check 1 record on the reference sheet at a time.
I want to use something like =IF(COUNTIF(B5:B9,"Product Type 1"),IF(COUNTIF(E2:E100,Reference!B2:B25),TRUE,FALSE))
But this does not work as the Criteria of the COUNTIF is a range. Is their an alternative function i could use to do this?

1692752446668.png
 

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.
Welcome to the MrExcel board!

Can you show us a smallish snippet of the Reference sheet and explain in words which cells in B5:B9 in your sample above should be identified with the Conditional Formatting & why?

BTW, I suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with.
 
Upvote 0
Hi Peter_SSs thanks for the help. Unfortunately our work computers are quite restricted due to security concerns and I cannot install addons. I have created a sample reference sheet to help explain better. I also realized i need to modify the condition to allow for multiple colours.

I want B5:B9 to colour based on if the person has a product or not.

-If the Product type matches a Model number in E2:E100 color green (using reference table to determine what models are what type of product)
-If the Person has no models that match a product it should color red indicating they do not have one

So the formula would be something like
=IF(COUNTIF(B5:B9,"Laptop"),AND(IF(COUNTIF(E2:E100,Reference!B2:B12),TRUE,FALSE)) - Format Laptop to be Green if a model in E2:E100 matches the reference sheet
=IF(COUNTIF(B5:B9,"Laptop"),AND(NOT(IF(COUNTIF(E2:E100,Reference!B2:B12),TRUE,FALSE)))) - Format Laptop to be Red if no cells in E2:E100 match the laptop reference sheet

=IF(COUNTIF(B5:B9,"Monitor"),AND(IF(COUNTIF(E2:E100,Reference!C2:C12),TRUE,FALSE)) - Format Monitor to be Green if a model in E2:E100 matches the reference sheet
=IF(COUNTIF(B5:B9,"Monitor"),AND(NOT(IF(COUNTIF(E2:E100,Reference!C2:C12),TRUE,FALSE)))) - Format Laptop to be Red if no cells in E2:E100 match the laptop reference sheet


I will need to create a conditional format for B5:B9 for each Product Type to colour Red/Green based off the model list in E2:E100


Lookup Sheet example:
Laptop is Green as they have 1 match
Monitor is Green as the have 2 matches
Vehicle is Green as they have 1 match
Phone is Red as they have 0 matches

1692761832609.png


Reference:

1692761842190.png


Let me know if that is enough info. If not i will try create a sample sheet on a personal computer that i can provide.
 
Upvote 0
Unfortunately our work computers are quite restricted due to security concerns and I cannot install addons.
Fair enough. In the future best to mention that in post 1 to stop us continually asking. :)
For small samples like you had, you can simply copy/paste from Excel in to the forum an explain what the range is.

I will need to create a conditional format for B5:B9 for each Product Type to colour Red/Green based off the model list in E2:E100
If I have understood correctly, I don't think so.

You may have to adjust the ranges to suit your data but see if this is headed in the right direction.

Vesp.xlsm
BCDEF
1LaptopMonitorVehiclePhoneProd 5
2xqqqz1Pr-1
3rbwwz2Pr-2
4tpeez3Pr-3
5alrrz4Pr-4
6qzcz5Pr-5
7wmyyz6
8kuuz7
9dii
10g
11
Reference


Vesp.xlsm
BCDE
1
2Model
3a
4Productb
5Laptopc
6Monitord
7Vehicle
8Phone
9Prod 5
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B5:B9Expression=COUNT(MATCH(FILTER(Reference!B$2:F$100,Reference!B$1:F$1=B5,""),E:E,0))=0textNO
B5:B9Expression=COUNT(MATCH(FILTER(Reference!B$2:F$100,Reference!B$1:F$1=B5,""),E:E,0))>0textNO
 
Upvote 0
Solution
Great solution, Thanks Peter!

works perfectly. i was concerned due to B5:B9 values changing based on the person selected the formula may get confused but your solution using FILTER 'include' was just what I needed.
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

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