How to remove duplicates in Excel
SheetFluent team · · 6 min read
Select your data, go to Data > Remove Duplicates, check the columns that must match, and click OK. Excel keeps the first copy of each row and deletes the rest. If you want to see what will go before anything is deleted, add a helper column with =IF(, check the rows marked Remove, then filter and delete them.
=IF(COUNTIF($A$2:A2,A2)>1,"Remove","Keep")
Remove duplicates with the button
The Remove Duplicates command is the fastest way when you trust your data and just want the repeats gone. It works on a whole table in one step.
1. Click any cell inside your data. Excel picks up the whole block of filled cells around it. To work on only part of the sheet, select that range yourself first.
2. On the Data tab, in the Data Tools group, click Remove Duplicates.
3. Leave My data has headers ticked if row 1 holds column names like Name or Email. Excel then won't treat the headers as data.
4. Check the boxes of the columns that decide what a duplicate is. With every column checked, only rows that match in every column are removed. With only Email checked, two rows with the same email count as duplicates even if the names differ.
5. Click OK. Excel shows a message saying how many duplicate values it removed and how many unique values remain.
Excel keeps the first row of each group, the one nearest the top, and deletes the later copies. If the first copy is the one you want to lose (an old address, say), sort the data first so the row you want to keep comes higher up.
The change happens in place. Press Ctrl+Z straight away if the result looks wrong. For anything important, copy the sheet first so you have the original to go back to.
In Google Sheets
Google Sheets has the same tool under a different menu. Select the range, then go to Data > Data cleanup > Remove duplicates. Tick Data has header row if it does, choose the columns to compare, and click Remove duplicates. Sheets also keeps the first copy and tells you how many rows it removed.
Mark duplicates with a formula before you delete
The button doesn't show you which rows it removed. When the list matters (a customer list, an attendance register, an order export), mark the repeats with a formula first. Then you can look at them before they go.
The trick is a running count. In a new column next to your data, start with a count in row 2 and fill it down.
=COUNTIF( counts how many times the name in A2 appears from the top of the list down to this row. On the first copy of a name the answer is 1. On the second copy it's 2, on the third it's 3, and so on.
So any row with a count above 1 is a repeat of something higher up. Wrap it in IF to turn that into a plain label: =IF(.
Read it as: "if this name has already appeared above, write Remove, otherwise write Keep".
The dollar signs matter. $A$2 is locked, so the range always starts at the top. The second A2 has no dollar signs, so it moves down as you fill: in row 5 the range becomes $A$2:A5. That growing range is what makes the count "so far" and not "in the whole list".
=IF(COUNTIF($A$2:A2,A2)>1,"Remove","Keep")See also: Lock a cell with $, How to find duplicates in Excel with COUNTIF
Delete the marked rows
1. Click a cell in your header row and turn on a filter: Data > Filter in Excel, or Data > Create a filter in Google Sheets.
2. Open the filter on the helper column and show only Remove.
3. Select the visible rows by their row numbers, right-click, and choose Delete Row. Only the filtered rows are deleted.
4. Clear the filter. Every name now appears once. You can delete the helper column, or keep it if you'll add more rows later.
One thing to watch: the formula looks at the rows above. If you sort the data after adding the helper column, the labels recalculate for the new order. That's fine, but check the labels again after any sort, before deleting.
When duplicates depend on more than one column
Sometimes a name on its own isn't enough. Two people called Sam Lee might be different people in different cities. In that case, count rows where both columns match so far. COUNTIFS (COUNTIF with several conditions) does this:
=IF( reads as "if this name and this city have both appeared together above, write Remove".
With the Remove Duplicates button, the same idea is just ticking both columns in the dialog.
See also: Count with two conditions using COUNTIFS
Why some duplicates aren't removed
If two rows look the same but stay, the cells are not truly equal. The usual causes:
Extra spaces. "Rosa Diaz" and "Rosa Diaz " (with a space at the end) are different text. Clean the column with TRIM in a helper column, =TRIM(, then paste the results back as values before removing duplicates.
Numbers stored as text. An ID typed as text and the same ID stored as a number won't match. Convert them to one type first.
Different columns ticked. If you ticked every column, a row that differs only in a date or a note column is not a duplicate.
Capital letters don't matter. Remove Duplicates and COUNTIF both treat "ROSA DIAZ" and "Rosa Diaz" as the same.
Keep the original and make a clean list
If you want a list of each value once without touching the original, copy the column to a new place and run Remove Duplicates on the copy. Newer versions of Excel and Google Sheets also have a UNIQUE function that builds the list for you, but the copy-and-remove method works in every version.
To check what you removed, compare row counts before and after. =COUNTA( counts the filled cells in a column, so run it on both lists.
See also: List each value once with UNIQUE
Try it here
Type the formula into the answer cell, then press Enter or Check.
In B2, write a formula that says Remove for a name that already appeared above, and Keep otherwise. It will be filled down to B8.
| A | B | |
|---|---|---|
| 1 | Name | Keep? |
| 2 | Rosa Diaz | (answer cell) |
| 3 | Tom Lee | |
| 4 | Rosa Diaz | |
| 5 | Ken Ito | |
| 6 | Tom Lee | |
| 7 | Amy Fox | |
| 8 | Rosa Diaz |
In B2, write a formula that says Remove for a name that already appeared above, and Keep otherwise. It will be filled down to B8.
Start practicingQuestions people ask
Which copy does Remove Duplicates keep?
The first one, nearest the top of the range. Sort your data first if you want a particular copy, such as the newest, to be the one that stays.
Can I undo Remove Duplicates?
Yes, press Ctrl+Z straight after. Once you save and close the file, the removed rows are gone, so copy the sheet first when the data matters.
Is there a formula that removes duplicates?
A formula can't delete rows. It can mark them: =IF( labels every repeat, and you then filter on Remove and delete those rows.
Does Remove Duplicates care about capital letters?
No. "ROSA DIAZ" and "Rosa Diaz" count as the same value. Extra spaces do matter, so run TRIM on the column first if some copies stay.
Keep practicing
Practice this in the full lesson: Count what matches with COUNTIF
Related articles
Find duplicates in Excel with =COUNTIF($A$2:$A$8,A2)>1: TRUE marks every value that appears more than once. Highlight or count them.
Return a value when a cell contains a word in Excel: =IF(COUNTIF(A2,"*fragile*"),"Yes","No") finds it anywhere.
Look up a value that matches two conditions in Excel: join them with & in a helper column, then use XLOOKUP or INDEX MATCH.