Summary

Excel contains many built-in "presets" for highlighting values with conditional formatting, including a preset to highlight unique values. However, if you want more flexibility, you can highlight unique values with your own formula, as explained in this article.

To highlight cells that contain unique values in a set of data, you can use a formula that returns TRUE when a value appears just once. For example, if you have values in the cells A1:D10, and want to highlight cells with duplicate values, you can use this formula:

=COUNTIF($A$1:$D$10,A1)=1

Note: with conditional formatting, the formula must be entered relative to the "active cell" in the selection, which is assumed to be A1 in this case.

Generic formula

=COUNTIF(data,A1)=1

Explanation 

The COUNTIF function counts the number of times each value appears in the data range. By definition, each value must appear at least once, so when the count equals 1, the value is unique. When the count is 1, the formula returns TRUE and triggers the rule.

Conditional formatting is evaluated for each cell that is applied to. When you use a formula to apply conditional formatting, the formula is evaluated relative to the active cell in the selection at the time the rule is created. In this case, the range we are using in COUNTIF is locked with an absolute address, but A1 is fully relative. So, the rule is evaluated for each of the 40 cells in A1:D10, and A1 will be updated to a new address 40 times (once per cell) while $A$1:$D$10 remains unchanged.

Named ranges for a cleaner syntax

Another way to lock references is to a named range since named ranges are automatically absolute. For example, if you name the range A1:D10 "data", you can rewrite the rule with a cleaner syntax like so:

=COUNTIF(data,A1)=1
Dave Bruns Profile Picture

AuthorMicrosoft Most Valuable Professional Award

Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.