FormulaCraft

How to highlight duplicate values in Excel and Google Sheets

Topic:Conditional formatting
Excel & Google Sheets
=COUNTIF($A$2:$A$6,A2)>1

Verified example

Computed by a real spreadsheet engine on the sample data below.

Name
Alice
Bob
Alice
Carol
Bob

=COUNTIF($A$2:$A$6,A2)>1TRUE

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1Select the range you want to check (e.g., A2:A6).
  2. 2Open Conditional Formatting: Home → Conditional Formatting → New Rule (Excel) or Format → Conditional Formatting (Sheets).
  3. 3Choose 'Use a formula' and enter =COUNTIF($A$2:$A$6,A2)>1 — lock the range but leave the cell reference relative so each row checks itself.

Tips

Need it for your exact data?

Describe your columns in plain English and get the precise formula for your sheet, with the right Excel or Sheets syntax.

Frequently asked

How do I highlight only the second occurrence, not the first?

Use =COUNTIF($A$2:A2,A2)>1 with a mixed reference — the range expands row by row, so the first occurrence sees a count of 1 and is not highlighted.

Can I highlight duplicates across two columns?

Yes — expand the COUNTIF range to cover both columns: =COUNTIF($A$2:$B$6,A2)>1.

More on Conditional formatting

See all →

Formulas used

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: