How-to recipes · Cleaning data
How to remove duplicates in Excel
Delete repeated rows with Data > Remove Duplicates, keep the original intact with UNIQUE, or flag duplicates with COUNTIF in older Excel.
A mailing list exported from two systems, a list of invoices pasted twice, a sign-up sheet where people registered more than once: duplicates creep into every spreadsheet. If you send an email to that list, some people get it twice; if you total those invoices, the sum is too high. This recipe shows three ways to get rid of repeated rows, from the one-click button to a live formula, and explains what Excel considers a duplicate so you do not delete the wrong rows.
The example data
A contact list in A1:B7. Ana Silva and Ben Ortiz each appear twice, so 6 rows should become 4.
Microsoft 365 and Excel 2021: UNIQUE keeps the original
The safest method does not delete anything. Type UNIQUE in an empty cell and it spills a clean copy of the list that updates when the source changes:
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Name | ||||
| 2 | Ana Silva | ana@example.com | Ana Silva | ana@example.com | |
| 3 | Ben Ortiz | ben@example.com | Ben Ortiz | ben@example.com | |
| 4 | Ana Silva | ana@example.com | Chloe Wu | chloe@example.com | |
| 5 | Chloe Wu | chloe@example.com | Dev Patel | dev@example.com | |
| 6 | Ben Ortiz | ben@example.com | |||
| 7 | Dev Patel | dev@example.com |
UNIQUE compares whole rows (name and email together) and keeps the first occurrence of each.
Wrap it in SORT to get the list in alphabetical order: =SORT(UNIQUE(A2:B7)). To check one column only, for example emails, use =UNIQUE(B2:B7). Because the result is a formula, you cannot type into it; copy it and use Paste Special > Values if you need a static list.
Any version: the Remove Duplicates button
This changes the data in place, so work on a copy or make sure you can undo.
- Click any cell inside the list.
- Go to Data > Data Tools > Remove Duplicates.
- Tick My data has headers if row 1 holds column names.
- Tick the columns that define a duplicate. Leave all ticked to remove only rows that are identical in every column; tick only Email to keep one row per email address even if the name is spelled differently.
- Click OK. Excel reports how many duplicate values were removed and how many unique values remain (here: 2 removed, 4 remain).
Excel 2016 and 2019: flag duplicates with COUNTIF first
When you want to review duplicates before deleting them, add a helper column. In C2 count how many times this email has appeared so far, using a range that grows as you copy down:
| A | B | C | |
|---|---|---|---|
| 1 | Name | Seen | |
| 2 | Ana Silva | ana@example.com | |
| 3 | Ben Ortiz | ben@example.com | |
| 4 | Ana Silva | ana@example.com | 2 |
| 5 | Chloe Wu | chloe@example.com | |
| 6 | Ben Ortiz | ben@example.com | |
| 7 | Dev Patel | dev@example.com |
Row 4 is the second time ana@example.com appears, so the count is 2. Copy the formula from C2 down to C7.
Result: 2
Every row with a 1 is the first occurrence; anything greater than 1 is a repeat. Filter column C for values greater than 1 (Sorting and filtering data), select the visible rows, delete them and clear the filter. The mixed reference $B$2:B4 is the key: the start is locked and the end moves, a technique explained in Cell references: relative, absolute and mixed.
Advanced Filter: a copy without duplicates
Excel 2016 and 2019 also have a built-in way to copy only unique rows: Data > Sort & Filter > Advanced, choose Copy to another location, set the list range and a destination cell, and tick Unique records only. The original stays untouched. Unlike UNIQUE it does not update automatically.
What counts as a duplicate
- Comparison is not case-sensitive:
ana@example.comandANA@example.comare duplicates for both Remove Duplicates and UNIQUE. - Spaces matter:
Ana SilvaandAna Silva(with a trailing space) are different. Run TRIM over the column first, see How to remove spaces in Excel. - Remove Duplicates compares what the cells display, not what they store. The same date formatted as 2026-03-15 in one cell and 15-Mar-2026 in another is treated as two different values, so apply one number format to the whole column first.
- Hidden rows are included. Remove Duplicates works on all rows in the range, filtered or not.
Power Query for repeated imports
If the same messy file arrives every week, load it with Data > From Table/Range, select the key columns in the Power Query editor and choose Home > Remove Rows > Remove Duplicates. Next week you only click Refresh. Power Query is available in Excel 2016 and later; Power Query basics: import, clean, append, merge, refresh shows the first steps. The complete cleaning workflow is in Removing duplicates and cleaning data.
⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 14 KB