WP Workflow Picks
excelconditional formattingduplicates

Excel Highlight Duplicates: Built-in Rule, Formulas and Fixes

How to highlight duplicates in Excel with the built-in rule, COUNTIF formulas for whole rows, case-sensitive checks, and the 15-digit long-number trap.

WP Workflow Picks team · · 5 min read · 7 sources
Churchill Club Top 10 Tech Tech Trends Debate 2013 — I chose Deep Learning / Machine Learning
Photo: jurvetson (CC BY 2.0) via Openverse

To highlight duplicates in Excel, select the cells you want to check, then go to Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values, pick a format and click OK. That built-in rule covers most cases; for whole rows, case-sensitive matching or long ID numbers you need a formula rule, which this guide walks through below.

The menu paths here match Microsoft’s current support documentation as of November 2026. Excel’s ribbon changes occasionally, so labels may shift slightly between versions.

The quick way: the built-in Duplicate Values rule

Microsoft’s Find or highlight duplicates article describes the standard method:

  1. Select the range you want to check (for example, a column of email addresses).
  2. On the Home tab, in the Styles group, select Conditional Formatting.
  3. Choose Highlight Cells Rules > Duplicate Values.
  4. In the dialog, keep Duplicate in the left drop-down and choose a format on the right (such as light red fill with dark red text).
  5. Select OK.

Every value that appears more than once in your selection is now colored, including the first occurrence. Nothing is deleted or changed, which is exactly why Microsoft’s Find and remove duplicates page recommends highlighting first: you can review the matches before deciding what to remove.

Highlight unique values instead

The same dialog works in reverse. Switch the left drop-down from Duplicate to Unique, and Excel colors only the values that appear once in the selected range. This is handy when you want to spot the odd one out in a list that should be mostly repeats.

When the built-in rule isn’t enough

The preset rule has real limits. It only colors individual cells, it ignores letter case, and it can be fooled by long numbers. Here is a quick comparison of the options:

GoalMethodNotes
Flag repeated values in a columnBuilt-in Duplicate Values ruleFastest; colors every copy, including the first
Color the whole row when a key column repeatsFormula rule with COUNTIFLock the key column with $
Flag only the second copy onwardFormula rule with an expanding rangeLeaves the first occurrence uncolored
Match “Apple” but not “apple”Formula rule with SUMPRODUCT and EXACTBuilt-in rule is not case-sensitive
Long IDs or card numbersText-based formula or modified valuesExcel compares only 15 significant digits

All formula rules are created the same way:

  1. Select the full range the rule should color.
  2. Go to Home > Conditional Formatting > New Rule.
  3. Choose Use a formula to determine which cells to format.
  4. Enter the formula, written for the top-left cell of your selection.
  5. Click Format, choose a fill, and select OK twice.

Highlight entire rows based on one column

Say your data is in A2:C100 and column B holds customer IDs. Select A2:C100 and use:

=COUNTIF($B$2:$B$100,$B2)>1

The $ before the column letter in $B2 keeps every cell in the row looking at column B, while the row number stays relative so the rule moves down with each row. The fixed range $B$2:$B$100 is the list being searched.

Flag only the repeats, not the first occurrence

If you want the first instance left alone so you can see which rows are “extra,” anchor the start of the range and let the end grow:

=COUNTIF($B$2:$B2,$B2)>1

On each row, COUNTIF only looks at the rows above and including the current one, so the first occurrence counts as 1 and stays unformatted. Test this on a copy of your data first; it relies on the rows staying in their current order.

Duplicates within the same row

Sometimes the question is whether a single row repeats a value across columns, such as the same name entered twice in a schedule. A Microsoft Q&A answer suggests selecting the rows (starting at row 3 in that example, columns A to E) and using:

=COUNTIF($A3:$E3,A3)>1

Here the columns are locked and the row is relative, the opposite of the whole-row example above.

Case-sensitive duplicates

The built-in rule and COUNTIF both treat “SAY” and “say” as the same value. For a case-sensitive check in column A, a rule confirmed working in an Excel Forum thread is:

=AND(A1<>"",SUMPRODUCT(EXACT($A$1:$A$1000,A1)*1)>1)

EXACT compares text character for character, including case. The A1<>"" part stops blank cells from being flagged as duplicates of each other. EXACT also treats wildcard characters like * and ? as plain text, which COUNTIF does not.

SUMPRODUCT over a large range can slow down big workbooks, so keep the range close to the size of your actual data.

The long-number trap (IDs, barcodes, card numbers)

A common complaint on the Microsoft Tech Community is that Excel highlights two clearly different long numbers as duplicates. The cause: when comparing, Excel converts number-like text to numbers and only considers the first 15 significant digits. Two 16-digit values that share their first 15 digits look identical to both the Duplicate Values rule and COUNTIF.

Workarounds discussed in those threads:

  • Add a letter to the values (before or after the digits, but not an apostrophe) so Excel can’t treat them as numbers.
  • Use a text comparison such as the SUMPRODUCT/EXACT formula above, which compares full strings. Make sure the cells are actually stored as text.

If the digits were already lost because the values were typed or imported as numbers and the file was saved, no formatting rule can bring them back. You’ll need to re-import the original data as text.

After highlighting: removing duplicates safely

Once you’ve reviewed the highlighted cells, you can delete duplicates with Excel’s dedicated command. Per Microsoft’s Filter for unique values or remove duplicate values page:

  1. Select the range, or click any cell inside a table.
  2. On the Data tab, in the Data Tools group, select Remove Duplicates.
  3. Tick the columns that define a duplicate and select OK.

Microsoft is clear about the difference: filtering for unique values only hides duplicates temporarily, while Remove Duplicates permanently deletes them. Work on a copy of the sheet if you might need the original rows later.

Managing and clearing your rules

If colors start appearing in odd places, it’s usually because a rule was applied to the wrong range or several rules overlap. Go to Home > Conditional Formatting > Manage Rules to see every rule on the sheet, edit its formula or “Applies to” range, or delete it. To wipe formatting from a selection or the whole sheet, use Conditional Formatting > Clear Rules.

A few habits that save time:

  • Select the exact data range before creating a rule, rather than whole columns, so blank cells and headers aren’t swept in.
  • Write formulas for the top-left cell of your selection; Excel adjusts them for every other cell.
  • Remember that highlighting doesn’t work in a PivotTable’s Values area, according to Microsoft. Run your duplicate checks on the source data instead.

Frequently asked questions

Why does Excel highlight two long numbers as duplicates when they are different? +

Excel compares number-like values using only the first 15 significant digits, so card numbers or IDs that share a 15-digit prefix look identical to the duplicate rule and to COUNTIF. Adding a non-numeric character to the values, or using a SUMPRODUCT/EXACT formula on text, avoids the false match.

Is Excel's Duplicate Values rule case-sensitive? +

No. The built-in rule treats "Apple" and "apple" as the same value. If case matters, use a formula rule built on EXACT, such as =AND(A1<>"",SUMPRODUCT(EXACT($A$1:$A$1000,A1)*1)>1).

Does highlighting duplicates delete anything? +

No. Conditional formatting only changes how cells look, so it is a safe way to review matches first. Data > Remove Duplicates is the command that permanently deletes rows.

Can I highlight duplicates inside a PivotTable? +

Not in the Values area. Microsoft's support page notes that Excel can't highlight duplicates in the Values area of a PivotTable report, so check the source data instead.

Sources

  1. Find and remove duplicates (Microsoft Support) (support.microsoft.com)
  2. Find or highlight duplicates (Microsoft Support) (support.microsoft.com)
  3. Filter for unique values or remove duplicate values (Microsoft Support) (support.microsoft.com)
  4. How to highlight duplicate values on the same row? (Microsoft Q&A) (learn.microsoft.com)
  5. Value not same but is highlighted as duplicate in conditional formatting (Microsoft Tech Community) (techcommunity.microsoft.com)
  6. Highlight duplicates for case-sensitive matches (Excel Forum) (excelforum.com)
  7. How to find and highlight duplicates in Excel (IONOS Digital Guide) (ionos.com)
About this guide. Researched and drafted with AI assistance from the sources above, then checked against our editorial rules. It reflects what was publicly known on November 22, 2026; details can change, so confirm with the official source before acting on it. How we work →

Our reviews

In-depth reviews from Workflow Picks that go with this topic.

Keep reading