Highlight Duplicate Values With Color
You want duplicate entries to jump out visually — colored cells you can spot while scrolling — instead of adding a helper column and filtering for repeats.
Excel & Google Sheets
This formula works in both Excel and Google Sheets.
How it works
This formula doesn't go in a cell — it goes inside a conditional formatting rule, where it's evaluated once for every selected cell and colors the ones that return TRUE. COUNTIF($A$2:$A$20,A2) counts how many times each cell's value appears in the whole range; a count above 1 means duplicate, so every copy gets highlighted. In Excel: select A2:A20, then Home > Conditional Formatting > New Rule > "Use a formula to determine which cells to format", paste the formula, and pick a fill color. In Google Sheets: select A2:A20, then Format > Conditional formatting, set the condition to "Custom formula is", and paste the same formula. Write the formula from the perspective of the top-left cell of your selection (A2 here) — both apps adjust it automatically for every other cell.
When to use it
Use this on any column where repeats mean trouble: invoice numbers, employee IDs, email lists, booking references. The color updates live, so new duplicates light up the moment they're typed.
Common mistakes
Did this formula help?
Engine-verified against the sample data aboveLast reviewed 2026-07-08