Formula to highlight cells if one cell contains specific text and another cell has only one of two requirements

kmsprague

New Member
Joined
Nov 14, 2022
Messages
28
Office Version
  1. 365
Platform
  1. Windows
Hi all,
I'm working with a list where I need to catch anyone who isn't meeting a requirement. In short, the requirement is that if you are enrolled in "ABC" plan then you also have to be enrolled in "DEF" plan. So if a person is correct with their enrollment, they will have more than one line listed in the report. What I want to do is have the cells in column A highlight for a person if they have ABC but don't have DEF. I've tried this formula in conditional formatting, but it isn't narrowing it down as I'd hoped. =AND(UNIQUE(A2:A3),C2,"*ABC*") I'm not sure if using unique is the way to go, so I'm open to all ideas/suggestions. Thank you in advance for your help!

In the example below, Jennifer Lopez's personnel number would be highlighted because she doesn't have both plans.

1705444549514.png
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Try:
Libro1
ABC
1NumNamePlan
21BrooksABC
31BrooksDEF
43JenABC
54WillDEF
68DamDEF
78DamABC
Hoja1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A7Expression=COUNTIFS(A:A,A2,C:C,"ABC")+COUNTIFS(A:A,A2,C:C,"DEF")=1textNO
 
Upvote 0
Try:
Libro1
ABC
1NumNamePlan
21BrooksABC
31BrooksDEF
43JenABC
54WillDEF
68DamDEF
78DamABC
Hoja1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A7Expression=COUNTIFS(A:A,A2,C:C,"ABC")+COUNTIFS(A:A,A2,C:C,"DEF")=1textNO
Hi there! This was very helpful! I only ran into one problem, though. There are other plans listed in the report, so this highlighted everyone who didn't have one of these plans. I guess what I'm trying to say is to highlight anyone who has ABC without DEF, but not the other way around. Someone can have DEF on its own, so it's really the combination I'm trying to look for. I'm hope this makes sense.
 
Upvote 0
Like this?

24 01 17.xlsm
ABC
1NumNamePlan
21BrooksABC
31BrooksDEF
43JenABC
54WillDEF
68DamDEF
78DamABC
Check
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A7Expression=AND(C2="ABC",COUNTIFS(A$2:A$7,A2,C$2:C$7,"DEF")=0)textNO
 
Upvote 1
Try:

Excel Formula:
=AND(C2="ABC",COUNTIFS(A:A,A2,C:C,"ABC")+COUNTIFS(A:A,A2,C:C,"DEF")=1)
 
Upvote 1
Solution
Like this?

24 01 17.xlsm
ABC
1NumNamePlan
21BrooksABC
31BrooksDEF
43JenABC
54WillDEF
68DamDEF
78DamABC
Check
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A7Expression=AND(C2="ABC",COUNTIFS(A$2:A$7,A2,C$2:C$7,"DEF")=0)textNO
Yes, this works! Thank you!
 
Upvote 0
You're welcome. Glad we could help.

Just wondering with your data, is something like this possible where 3/Jen is listed with "ABC" twice (or more) but not with "DEF"?
IF YES, my formula would highlight both ..

24 01 17.xlsm
ABC
1NumNamePlan
21BrooksABC
31BrooksDEF
43JenABC
54WillDEF
68DamDEF
73JenABC
Check
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A7Expression=AND(C2="ABC",COUNTIFS(A$2:A$7,A2,C$2:C$7,"DEF")=0)textNO


.. and Dante's would highlight neither

24 01 17.xlsm
ABC
1NumNamePlan
21BrooksABC
31BrooksDEF
43JenABC
54WillDEF
68DamDEF
73JenABC
Check (2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A7Expression=AND(C2="ABC",COUNTIFS(A:A,A2,C:C,"ABC")+COUNTIFS(A:A,A2,C:C,"DEF")=1)textNO


IF NO, then both formulas would work but there is an extra check in Dante's formula that is not required. :)
 
Upvote 0
Thankfully, that isn't an issue at this time, but if that changes I sure appreciate this option! Thank you very much!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
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