Finding and removing duplicates in Excel
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
| Way | What it does | Use it when |
|---|---|---|
| 1. Highlight with Conditional Formatting | Colours every value that appears more than once. No formula, nothing deleted. | You want a quick look at one column. |
| 2. Flag with COUNTIF | Puts 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 Duplicates | Deletes 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 UNIQUE | Spills 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
- Select the column to check, such as A2:A7.
- Go to Home › Conditional Formatting › Highlight Cells Rules › Duplicate Values. The menus are the same in Excel for Mac.
- 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)
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Member ID | Name | Count | First copy? |
| 2 | M-104 | Amira | 2 | Keep |
| 3 | M-221 | Ben | 2 | Keep |
| 4 | M-104 | Amira | 2 | Duplicate |
| 5 | M-315 | Cara | 1 | Keep |
| 6 | M-221 | Ben | 2 | Duplicate |
| 7 | M-402 | Dev | 1 | Keep |
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.
- Click any cell in the data.
- Go to Data › Remove Duplicates. It's in the same place on a Mac.
- 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.
- 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.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Member ID | Name | Each once | Only once | Repeated rows | ||
| 2 | M-104 | Amira | M-104 | M-315 | M-104 | Amira | |
| 3 | M-221 | Ben | M-221 | M-402 | M-221 | Ben | |
| 4 | M-104 | Amira | M-315 | M-104 | Amira | ||
| 5 | M-315 | Cara | M-402 | M-221 | Ben | ||
| 6 | M-221 | Ben | |||||
| 7 | M-402 | Dev |
The three formulas answer three different questions:
- Each once,
=UNIQUE(A2:A7): every member, with no repeats. 4 IDs. - Only once,
=UNIQUE(A2:A7,,TRUE): the members who appear exactly once, M-315 and M-402. The TRUE in the third place means "exactly once". - Repeated rows,
=FILTER(A2:B7,COUNTIF(A2:A7,A2:A7)>1): every row whose ID is repeated, so you can see them side by side. COUNTIF counts each ID, and FILTER keeps the rows where the count is over 1.
How many duplicates are there?
"How many duplicates" can mean two things, and they give different numbers for the same list:
- How many rows would be deleted? 6 rows, 4 different members, so 6 − 4 = 2 extra copies. In Excel 365 or 2021:
=ROWS(A2:A7)-COUNTA(UNIQUE(A2:A7)). - How many rows have a repeated ID? M-104 twice and M-221 twice, so 4. In any Excel:
=SUMPRODUCT(--(COUNTIF(A2:A7,A2:A7)>1)).
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)
| A | B | C | |
|---|---|---|---|
| 1 | Name | Date | Bookings |
| 2 | Amira | 03/12/2026 | 2 |
| 3 | Ben | 03/12/2026 | 1 |
| 4 | Amira | 10/12/2026 | 1 |
| 5 | Amira | 03/12/2026 | 2 |
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
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.
| A | B | C | |
|---|---|---|---|
| 1 | Order ID | Customer | Times listed |
| 2 | A-1001 | Harbour Catering | |
| 3 | A-1002 | Ashby Stationers | |
| 4 | A-1003 | Kestrel Print | |
| 5 | A-1002 | Ashby Stationers | |
| 6 | A-1004 | Northgate Supplies | |
| 7 | A-1001 | Harbour Catering | |
| 8 | A-1005 | Kestrel Print | |
| 9 | A-1001 | Harbour 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.