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.

Beginner UNIQUE COUNTIF SORT TRIM

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:

D2fx=UNIQUE(A2:B7)
ABCDE
1NameEmail
2Ana Silvaana@example.comAna Silvaana@example.com
3Ben Ortizben@example.comBen Ortizben@example.com
4Ana Silvaana@example.comChloe Wuchloe@example.com
5Chloe Wuchloe@example.comDev Pateldev@example.com
6Ben Ortizben@example.com
7Dev Pateldev@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.

  1. Click any cell inside the list.
  2. Go to Data > Data Tools > Remove Duplicates.
  3. Tick My data has headers if row 1 holds column names.
  4. 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.
  5. Click OK. Excel reports how many duplicate values were removed and how many unique values remain (here: 2 removed, 4 remain).
Watch out. Remove Duplicates keeps the first row of each group and deletes the others, together with every other column of those rows. If a later row has a newer phone number, that information is lost. Sort the data first (for example newest date at the top) so the row you want to keep comes first.

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:

C4fx=COUNTIF($B$2:B4,B4)
ABC
1NameEmailSeen
2Ana Silvaana@example.com
3Ben Ortizben@example.com
4Ana Silvaana@example.com2
5Chloe Wuchloe@example.com
6Ben Ortizben@example.com
7Dev Pateldev@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.com and ANA@example.com are duplicates for both Remove Duplicates and UNIQUE.
  • Spaces matter: Ana Silva and Ana 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.
Tip. If you only want to see the duplicates rather than delete them, colour them with conditional formatting: How to highlight duplicates in Excel. To compare two separate lists, see How to find duplicates between two lists in Excel.

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

More how-to recipes