Confident CellsExcel practice Start free

Finding and removing duplicates in Excel

Updated 27 November 2026 · 6 min read

To find duplicates, count how many times each value appears: =COUNTIF($A$2:$A$9,A2). A count of more than 1 means it's a duplicate. To keep only the first copy, count from the top down to this row: =COUNTIF($A$2:A2,A2), and keep the rows where it's 1.

The 4 ways at a glance

WayWhat it doesUse it when
1. Highlight with Conditional FormattingColours every value that appears more than once. No formula, nothing deleted.You want a quick look at one column.
2. Flag with COUNTIFPuts a count, or Keep and Duplicate, next to every row.You want to check each one before deleting, or the list keeps growing.
3. Delete with Remove DuplicatesDeletes the repeated rows and keeps the first of each.You've checked, and want them gone in one go.
4. List each value once with UNIQUESpills a new list without repeats. The original stays as it is.You have Excel 365 or 2021 and want a list that updates itself.

All four are in Excel for Mac too, in the same places. Each one is worked through below with the same list of club members.

1. Highlight duplicates without a formula

  1. Select the column to check, such as A2:A7.
  2. Go to Home › Conditional Formatting › Highlight Cells Rules › Duplicate Values. The menus are the same in Excel for Mac.
  3. Leave the first box on Duplicate, pick a colour, and click OK.

Every copy is coloured, the first one included, so M-104 is coloured twice. Change the first box to Unique to colour the values that appear only once instead.

This rule checks single cells. It can't tell you that the same person booked the same date twice across two columns. For that, use a COUNTIFS rule, as in "Two columns at once" below, or see conditional formatting with a formula.

2. Flag every repeat with COUNTIF

COUNTIF counts how many cells in a range match. Give it the whole list, locked with $, and this row's value:

=COUNTIF($A$2:$A$9,A2)
ABCD
1Member IDNameCountFirst copy?
2M-104Amira2Keep
3M-221Ben2Keep
4M-104Amira2Duplicate
5M-315Cara1Keep
6M-221Ben2Duplicate
7M-402Dev1Keep
C2 holds =COUNTIF($A$2:$A$7,A2), and D2 holds =IF(COUNTIF($A$2:A2,A2)=1,"Keep","Duplicate"), both copied down.

M-104 and M-221 both appear twice, so both of their rows show 2. Filter column C for anything other than 1 to see every row involved. To colour the repeats with your own rule instead, use the same COUNTIF as a conditional formatting rule: =COUNTIF($A$2:$A$7,$A2)>1.

More on how COUNTIF works is in COUNTIF with a worked example.

Keep the first copy

Lock only the start of the range: $A$2:A2. As the formula is copied down, the range grows, so each row counts how many times the ID has appeared so far. The first time, that's 1.

=IF(COUNTIF($A$2:A2,A2)=1,"Keep","Duplicate")

In row 4, the range is A2:A4. M-104 is in A2 and A4, so the count is 2 and the row says Duplicate. Back in row 2, the range is just A2, so the count is 1 and it says Keep. Filter on Duplicate to check them, then delete those rows.

Want to keep the latest copy instead, such as the newest address for each member? Sort the data newest first before you add the formula, so the latest copy is the one at the top.

3. Remove duplicates with the button

Excel can delete the repeated rows for you. It keeps the first copy of each and deletes the rest, so copy the data first: right-click the sheet tab (on a Mac, Control-click it), choose Move or Copy, tick Create a copy and click OK.

  1. Click any cell in the data.
  2. Go to Data › Remove Duplicates. It's in the same place on a Mac.
  3. Tick the columns that must all match for two rows to count as the same. Tick only Member ID to remove repeated members; tick every column to remove only rows that are exact copies.
  4. Click OK. Excel says how many duplicates it removed and how many rows are left.

In the example, ticking Member ID removes 2 rows (the second M-104 and the second M-221) and leaves 4. If that's not what you expected, press Ctrl+Z (Cmd+Z on a Mac) straight away to undo it.

The button is a one-off. Add more rows later and you have to do it again.

4. A list without repeats that updates: UNIQUE

In Excel 365 and 2021, =UNIQUE(A2:A7) spills a list with each member once, and leaves the original data alone. When the data changes, the list changes too. =UNIQUE(A2:B7) does the same for whole rows. See UNIQUE and FILTER.

ABCDEFG
1Member IDNameEach onceOnly onceRepeated rows
2M-104AmiraM-104M-315M-104Amira
3M-221BenM-221M-402M-221Ben
4M-104AmiraM-315M-104Amira
5M-315CaraM-402M-221Ben
6M-221Ben
7M-402Dev
D2 holds =UNIQUE(A2:A7), E2 holds =UNIQUE(A2:A7,,TRUE), and F2 holds =FILTER(A2:B7,COUNTIF(A2:A7,A2:A7)>1). Each one spills down.

The three formulas answer three different questions:

How many duplicates are there?

"How many duplicates" can mean two things, and they give different numbers for the same list:

For the number of different values, there's more, including a formula for older Excel, in counting unique values.

Two columns at once

Has the same person booked the same date twice? A name on its own repeats, and so does a date, so neither column is enough by itself. COUNTIFS checks both together:

=COUNTIFS($A$2:$A$5,A2,$B$2:$B$5,B2)
ABC
1NameDateBookings
2Amira03/12/20262
3Ben03/12/20261
4Amira10/12/20261
5Amira03/12/20262
C2 holds =COUNTIFS($A$2:$A$5,A2,$B$2:$B$5,B2), copied down. Only Amira on 3 December is booked twice.

Amira appears three times, but only twice on 3 December, so only those two rows show 2. To check whether a value from one list is on a different list, rather than repeated in its own, see comparing two lists.

Common mistakes

Later copies show 1

The range wasn't locked, so it slid down as the formula was copied. The first copy of a duplicate still shows 2 or 3, but the ones further down only look from their own row down, so they show 1. Use $A$2:$A$9.

Duplicates that aren't found

"M-104" and "M-104 " (with a space) look the same but aren't. Tidy the column with TRIM first. Text copied from a web page can also hold a non-breaking space, which TRIM leaves alone: =TRIM(SUBSTITUTE(A2,CHAR(160)," ")) deals with both.

Capital letters

COUNTIF, Remove Duplicates and the highlight rule all ignore capitals, so "m-104" and "M-104" count as the same. If capitals matter, as they can in some reference codes, EXACT tells them apart: =SUMPRODUCT(--EXACT($A$2:$A$9,A2)) counts only exact matches.

Try it now

Your turn

In C2, count how many times each order ID appears in the whole list, so duplicates show 2 or more. Your formula will be copied down to C9.

ABC
1Order IDCustomerTimes listed
2A-1001Harbour Catering
3A-1002Ashby Stationers
4A-1003Kestrel Print
5A-1002Ashby Stationers
6A-1004Northgate Supplies
7A-1001Harbour Catering
8A-1005Kestrel Print
9A-1001Harbour Catering

Open this in Try a formula: the same sheet with the answer filled in, to change or share by link.

Part of Excel data cleaning practice: every lesson on the topic, with a project in Excel.

Questions

How do I highlight duplicates in Excel?

Select the column, then go to Home › Conditional Formatting › Highlight Cells Rules › Duplicate Values, the same on Windows and Mac. Pick a colour and click OK. Every copy is coloured, the first one included. To colour only the second and later copies, use a formula rule instead: =COUNTIF($A$2:$A2,$A2)>1.

Does Remove Duplicates keep the first or the last copy?

The first: it keeps the copy nearest the top and deletes the ones below it. To keep the newest copy instead, sort the data newest first, then use Data › Remove Duplicates. Copy the sheet before you start, because Excel doesn't show you which rows it removed.

How do I find duplicates across two columns?

Use COUNTIFS with a pair for each column: =COUNTIFS($A$2:$A$50,A2,$B$2:$B$50,B2). A count of 2 or more means another row has the same value in both columns, such as the same person booked on the same date. To delete those rows, select the data, go to Data › Remove Duplicates and tick both columns, on Windows or Mac.

Why doesn't Excel find duplicates that look the same?

Usually there's a hidden space at the end of one of them, or a non-breaking space from a web page. =TRIM(SUBSTITUTE(A2,CHAR(160)," ")) removes both. Numbers stored as text are another cause: 1001 typed in and 1001 pasted as text don't match in Remove Duplicates. Capital letters aren't the cause: COUNTIF and Remove Duplicates ignore them.