Duplicate rows creep into almost every list: a customer signs up twice, two exports get pasted together, or a form is submitted again. This guide shows three reliable ways to remove duplicates in Excel. You can delete them in place with the Remove Duplicates button, build a live de-duplicated list with the UNIQUE function, or copy unique records somewhere else with Advanced Filter. It also covers how to find and count duplicates before you delete anything.
=UNIQUE(B2:B13) instead (Excel for Microsoft 365 and Excel 2021 or later).The sample data
All examples use this small mailing list in A1:C13. Some people appear twice. Mia Patel appears with the same email but a different city, which shows why it matters which columns you compare.
| Row | Name | City | |
|---|---|---|---|
| 2 | Ava Brooks | ava.brooks@example.com | Denver |
| 3 | Liam Chen | liam.chen@example.com | Austin |
| 4 | Mia Patel | mia.patel@example.com | Seattle |
| 5 | Ava Brooks | ava.brooks@example.com | Denver |
| 6 | Noah Kim | noah.kim@example.com | Boston |
| 7 | Liam Chen | liam.chen@example.com | Austin |
| 8 | Zoe Garcia | zoe.garcia@example.com | Miami |
| 9 | Ethan Ross | ethan.ross@example.com | Denver |
| 10 | Mia Patel | mia.patel@example.com | Portland |
| 11 | Noah Kim | noah.kim@example.com | Boston |
| 12 | Grace Lee | grace.lee@example.com | Austin |
| 13 | Zoe Garcia | zoe.garcia@example.com | Miami |
The list has 12 rows but only 7 different email addresses. If you compare all three columns, there are 8 different rows, because the two Mia Patel rows have different cities.
Step 0: Find and count duplicates first
Before you delete anything, check what you are about to lose. Add a helper column in D and enter this in D2, then fill it down to D13:
=IF(COUNTIF($B$2:B2,B2)>1,"Duplicate","")
The range $B$2:B2 grows as you copy the formula down. Each row only counts the emails above and including itself. The first occurrence stays blank, and every later repeat is marked "Duplicate". In the sample, rows 5, 7, 10, 11 and 13 are marked, which makes 5 duplicate rows by email.
To treat a row as a duplicate only when every column matches, use COUNTIFS instead:
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2,$C$2:C2,C2)>1,"Duplicate","")
This version marks only 4 rows (5, 7, 11 and 13). Row 10 (Mia Patel, Portland) is no longer a duplicate because its city is different.
To count distinct emails without a helper column, use this classic formula. It works in every Excel version:
=SUMPRODUCT(1/COUNTIF(B2:B13,B2:B13))
It returns 7 for the sample data. Note that it returns a #DIV/0! error if the range contains blank cells.
Method 1: The Remove Duplicates button
This is the fastest way when you want to clean the data permanently.
- Click any cell inside the list (or select
A1:C13). - Go to Data > Data Tools > Remove Duplicates.
- Keep My data has headers ticked so row 1 is not treated as data.
- Tick the columns that define a duplicate, then click OK.
Excel keeps the first occurrence of each value and deletes the later ones. Then it tells you how many duplicates were removed and how many unique values remain. With the sample data:
- All three columns ticked: 4 rows removed, 8 remain. Both Mia Patel rows stay.
- Only Email ticked: 5 rows removed, 7 remain. The Portland row is removed because its email already appeared in row 4.
Remove Duplicates changes your data in place. Press Ctrl+Z right away if the result is wrong, or work on a copy of the sheet.
Method 2: The UNIQUE function (dynamic)
UNIQUE returns a de-duplicated copy of a range and leaves the original alone. If the source data changes, the result updates automatically. It is available in Excel for Microsoft 365, Excel 2021 and later, and Excel for the web.
=UNIQUE(array, [by_col], [exactly_once])
Unique values from one column
=UNIQUE(B2:B13)
Enter it in one cell, such as E2, and the results spill downward. For the sample data, it returns 7 emails in E2:E8, in the order they first appear.
Unique rows across several columns
=UNIQUE(A2:C13)
This compares whole rows and returns 8 rows (3 columns wide). It works the same way as Remove Duplicates with all columns ticked.
Values that appear exactly once
=UNIQUE(B2:B13,,TRUE)
Setting the third argument to TRUE returns only the items that are never repeated. In the sample, that is just ethan.ross@example.com and grace.lee@example.com. This is different from "remove duplicates", so use it only when that is what you need.
You can wrap UNIQUE in other functions. For example, =SORT(UNIQUE(B2:B13)) gives an alphabetical list, and =ROWS(UNIQUE(B2:B13)) counts the distinct emails (7).
Method 3: Advanced Filter (works in older Excel)
If your Excel version does not have UNIQUE and you do not want to change the original data, use Advanced Filter:
- Select
A1:C13, including the headers. - Go to Data > Sort & Filter > Advanced.
- Choose Copy to another location and pick a destination cell, such as
E1. - Tick Unique records only and click OK.
The result is a static copy of the 8 unique rows. Unlike UNIQUE, it does not update when the source changes, so run it again after edits.
How it works
All three methods keep the first occurrence of each value and drop the repeats. The difference is what they compare and where the result goes. Remove Duplicates compares the columns you tick and edits the data in place. UNIQUE compares the range you give it and returns a live result somewhere else. Advanced Filter compares whole rows of the selected range and writes a one-time copy. The COUNTIF helper column follows the same "first one wins" rule, so it is a good preview of what the other methods will remove.
Common mistakes
- Ticking the wrong columns. If you check only Name, two different people with the same name count as one. Decide what makes a record unique first. For a mailing list, that is usually the email.
- Hidden spaces. "ava.brooks@example.com" and "ava.brooks@example.com " (with a trailing space) are different text, so none of these methods treat them as duplicates. Clean the column first with a helper formula such as
=TRIM(B2). - Forgetting the header option. If My data has headers is unticked, Excel treats the header row as data.
- Blocking the spill range. If any cell below a UNIQUE formula already contains something, the formula shows
#SPILL!. Clear the cells or move the formula. - No backup. Remove Duplicates deletes rows permanently once you save. Keep a copy of the raw data.
FAQ
Which row does Excel keep when it removes duplicates?
The first one, counting from the top. To keep a different row (for example, the newest entry), sort the data first so that row comes first, then remove duplicates.
How do I remove duplicates in Google Sheets?
Google Sheets has Data > Data cleanup > Remove duplicates, which works much like the Excel button. The =UNIQUE(B2:B13) formula also works in Google Sheets and returns the same 7 emails for this sample.
Can I highlight duplicates instead of deleting them?
Yes. Use Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values, or use the COUNTIF helper column above. Note that the built-in rule highlights every copy, including the first occurrence.
Why does UNIQUE show #NAME? in my file?
Your Excel version does not support UNIQUE. Use the Remove Duplicates button or Advanced Filter instead. Both are available in much older versions.
Summary
Use Remove Duplicates for a quick, permanent cleanup. Use UNIQUE when you want a live list that updates with the source. Use Advanced Filter when you need a static copy in older Excel. Whichever you choose, decide which columns define a duplicate first, and preview the result with a COUNTIF helper column. For more cleanup techniques, see the Data Cleaning tutorials, or browse all Excel guides.
Comments
Post a Comment