This blog article is one out of two articles on the same subject.
Highlight duplicates where adjacent cell value meets criteria using conditional formatting in excel
Highlight duplicates where adjacent cell value meets criteria using conditional formatting in excel part 2
Question: How do I only highlight duplicates that occur for the second time or more in a list (Column B) and where an adjacent cell value (Column A) must meet a criteria? See picture below.
Answer: Here is the conditional formatting formula: =IF((COUNT(IF(($B$2:$B2=$B2)*($A$2:$A2=$E$1), 1, ""))>1)*($A2=$E$1), TRUE, FALSE)
How to apply the conditional formatting formula in excel 2007:
- Select the range (A2:B16)
- Click "Home" tab on the ribbon
- Click "Conditional formatting"
- Click "New rule..."
- Click "Use a formula to determine which cells to format"
- Click "Format values where this formual is true" window.
- Type =IF((COUNT(IF(($B$2:$B2=$B2)*($A$2:$A2=$E$1), 1, ""))>1)*($A2=$E$1), TRUE, FALSE)
- Click Format button
- Click "Fill" tab
- Select a color
- Click OK!
- Click OK!
Change the category (E1) and see how different cells being highlighted.
Download excel example file.
(Excel 97-2003 Workbook *.xls)
Functions in this article:
Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE
Counts the number of cells in a range that contain numbers