Choose Which Duplicate Excel Rows to Keep Before Deleting

Worried Remove Duplicates will throw away the wrong copy of a record? It keeps the topmost copy and deletes every later match as a whole row, so sort first and preview first. The command itself is Data > Remove Duplicates: check only the columns that must match and press OK.

Written for Excel for Microsoft 365 on Windows; the Mac and browser differences are covered further down.

How Excel decides what to delete

Three rules explain almost every surprise people get from Remove Duplicates:

  • The checked columns define a match. Two rows are duplicates when every checked column holds the same value. Unchecked columns are ignored during the comparison.
  • The whole row goes. Microsoft’s documentation is clear that the entire row is removed, not just the cells in the checked columns. A different phone number or city in an unchecked column is deleted along with the row.
  • The topmost copy wins. Excel keeps the first occurrence in the current sort order and deletes the ones below it. It never looks at which row is newer or more complete.

That third rule is why the preview matters. The table shows how the column choice changes the result for a typical contact list:

Columns you check What counts as the same record Good for Risk
Every column Rows identical in every cell Rows pasted twice by accident Low: a single differing cell keeps both rows
Email only Any rows sharing an address One row per customer High: an older row can outrank a newer one
Name and Date One person on one day Timesheets, sign-in logs Medium: name spelling must be consistent
Invoice number only Any rows with the same invoice Order exports with repeated headers High if one invoice legitimately has several lines

Leave out any column that is unique by design, such as a row ID, timestamp or “Imported on” column. If it stays checked, every row is different and Excel reports that it found nothing to remove.

Preview the rows that will be deleted

Nothing in this section changes your data. It shows you the casualties before there are any.

Make a safety copy

Removed rows come back with Ctrl+Z only while the workbook is still open, and AutoSave on a OneDrive or SharePoint file commits the change within moments. Right-click the sheet tab, choose Move or Copy, check Create a copy and click OK. If you only need one or two columns as a backup, the ways to copy a column in Excel are quicker than duplicating a large sheet.

Shade the repeated values

  1. Select the cells in the column that defines a match, for example the Email values in B2:B9. Leave the header out.
  2. On the Home tab, choose Conditional Formatting > Highlight Cells Rules > Duplicate Values.
  3. Keep Duplicate in the first box, pick a format and click OK.
Excel Duplicate Values dialog box over a customer list with repeated email addresses shaded light red
(1) Keep Duplicate selected, (2) choose a highlight format next to “values with,” and (3) click OK. Every email that appears more than once is shaded. (Illustration)

The shading marks every copy, including the one Excel will keep, so it tells you which values repeat but not which rows disappear. It also compares single cells, not whole rows, and can’t be applied to the Values area of a PivotTable.

Add a flag column that names the exact rows

A COUNTIFS formula can mark the second and later copies, which are precisely the rows Remove Duplicates deletes. If COUNTIF is new to you, the walkthrough on how to count a word in Excel with COUNTIF covers the basics.

  1. In the first empty column (E in the example later on), type the header Will delete?
  2. In E2, enter =COUNTIFS($B$2:B2,B2)>1 for an Email match. For a two-column rule (Name and Email), add a pair per column: =COUNTIFS($A$2:A2,A2,$B$2:B2,B2)>1.
  3. Double-click the fill handle to copy the formula to the bottom of the list.

The range starts at a locked cell and grows as it goes down, so each row compares itself only with the rows above it. The first copy shows FALSE; every later copy shows TRUE. Sort the list differently and the TRUE marks move, which makes this the quickest way to test a sort before you commit to it.

Keep a record of what you removed

For customer, payroll or inventory data, it helps to keep the deleted rows on a sheet of their own. Turn on Data > Filter, filter the flag column to TRUE, select the visible rows, copy them, and paste them onto a new sheet named something like Removed. Clear the filter afterward. Now anyone who asks where a record went can find it.

Before running the real command, delete the flag column or make sure it is unchecked in the dialog. TRUE and FALSE values make otherwise identical rows look different, so a checked flag column can stop Excel from finding exact copies.

Run Remove Duplicates on the Data tab

  1. Click one cell inside the list. Excel selects the whole connected block, header row included. If the list contains a blank row or column, select the full range yourself, because the automatic selection stops at the gap.
  2. Open the command. Select the Data tab, then Remove Duplicates in the Data Tools group. On a narrow window, the group may shrink to icons; hover to read the names. Keyboard users can press Alt, then A to reach the Data tab; the letters Excel then displays on the ribbon lead to the button, and they can vary by version and language.
Excel Data tab with the Remove Duplicates command highlighted in the Data Tools group above a selected customer list
(1) Open the Data tab, then (2) click Remove Duplicates in the Data Tools group. The selected list is outlined in green. (Illustration)
  1. Check My data has headers if row 1 holds column names. The list under Columns then shows names such as Email instead of Column C, and the header row stays out of the comparison.
  2. Set the match rule. Every column starts checked. For a partial match, click Unselect All and check only the columns you chose from the rules table.
Remove Duplicates dialog box with My data has headers checked and only the Email column selected under Columns
(1) Check My data has headers, (2) choose the columns that must match (here, only Email), and (3) click OK. (Illustration)
  1. Click OK and read the message. Excel reports how many duplicate values it removed and how many unique values remain. Compare that number with the count of TRUE flags from your preview. They should agree.

If you selected a single column inside a wider list, Excel shows a warning offering to expand the selection. Expand it. Continuing with one column deletes cells from that column only, the values below shift up, and names stop lining up with their emails.

Data formatted as an Excel table (Insert > Table or Ctrl+T) works the same way, and the table also carries the command on its own Table Design tab, in the Tools group. The table shrinks to fit the rows that remain.

Choose the copy that survives

Because Excel keeps the highest row, you choose the survivor by sorting before you delete. Pick the column that defines “best” and sort so the best copy lands on top:

  • Newest record: sort a Last Updated or Date column newest to oldest.
  • Biggest order or balance: sort the amount column largest to smallest.
  • Most complete row: add a helper column with =COUNTA(A2:D2), which counts the filled cells in each row, and sort it largest to smallest.

Use Data > Sort with the whole list selected so each row moves as a unit. Sorting one column on its own scrambles the records.

Worked example: an eight-row customer export

Taylor exports a contact list from a sign-up form. Alex Rivera and Priya Shah each signed up twice, with a newer address the second time, and Jordan Lee’s row was pasted twice. The data is fictional.

Row Name Email City Updated
2 Alex Rivera [email protected] Denver 3/2/2026
3 Jordan Lee [email protected] Austin 1/15/2026
4 Priya Shah [email protected] Seattle 11/20/2025
5 Alex Rivera [email protected] Boulder 8/19/2026
6 Sam Carter [email protected] Boston 2/10/2026
7 Jordan Lee [email protected] Austin 1/15/2026
8 Priya Shah [email protected] Portland 7/4/2026
9 Maria Gomez [email protected] Miami 5/30/2026

Three ways to run it give three different lists:

Approach Rows deleted Rows left Outcome
All columns checked, no sort 7 7 Only the pasted copy goes. Alex and Priya still appear twice.
Email only, no sort 5, 7, 8 5 Wrong survivors: Alex keeps Denver and Priya keeps Seattle, the older addresses.
Sort Updated newest first, then Email only The older Alex and Priya rows, the second Jordan row 5 Correct: Boulder and Portland stay.

With the flag column in place, Taylor would have seen TRUE on rows 5, 7 and 8 before sorting. Rows 5 and 8 hold the newer addresses, which is the clue that they were about to disappear.

Build a duplicate-free copy beside the original

Sometimes the original list has to stay as it is, for example when other sheets point at it. Both of these tools build a separate, duplicate-free copy.

UNIQUE (Excel for Microsoft 365, 2024, 2021 and the web)

The syntax is =UNIQUE(array,[by_col],[exactly_once]). Click an empty cell with plenty of room below and to the right, type the formula and press Enter. The result spills into as many cells as it needs and updates when the source changes.

  • =UNIQUE(A2:D9) returns each distinct row once.
  • =UNIQUE(B2:B9) returns each email address once.
  • =UNIQUE(B2:B9,,TRUE) returns only the addresses that appear exactly one time.
  • =SORT(UNIQUE(B2:B9)) sorts the result A to Z.

UNIQUE judges whole rows, so it has no “check these columns” option and no way to prefer the newest copy. Pair it with the FILTER function when you need conditions as well. If the source is an Excel table, point at the table column (for example =UNIQUE(Customers[Email])) and the list grows with the table. A #SPILL! error means something is sitting in the cells the result needs; Microsoft’s page on correcting a #SPILL! error lists every cause. Full argument details are on Microsoft’s UNIQUE function page.

Advanced Filter (any desktop version, including 2019 and 2016)

  1. Select the list with its header row. Advanced Filter compares every column in the range, so select only the columns that define a match. The copy then holds only those columns, so to keep whole records use Remove Duplicates on a copied sheet instead.
  2. Choose Data > Advanced (in the Sort & Filter group).
  3. Pick Copy to another location and click the top-left cell of an empty area in the Copy to box. Filter the list, in-place hides repeats instead, and Data > Clear brings them back.
  4. Check Unique records only and click OK.

The copy is a snapshot; rerun it if the source changes. Microsoft covers both tools on its page about filtering for unique values or removing duplicates.

Merge two lists and drop the overlap

Remove Duplicates compares rows within one list. Two lists sitting side by side, or on different sheets, are never compared with each other, so stack them first:

  1. Make sure both lists use the same columns in the same order.
  2. Paste the second list directly under the first, without its header row and without a blank row between them.
  3. Add a Source column that says List A or List B, if you want to know later where each surviving row came from. Leave it unchecked when you remove duplicates.
  4. Sort so the copy you prefer is on top (for example, List B first if it is the newer export), then run Remove Duplicates.

When the lists arrive as separate CSV files, combining them first is easier; see how to merge multiple CSV files into one. If you only need to check whether a record from one list appears in the other, a lookup is a better fit than deleting anything: the guide to XLOOKUP in Excel shows how.

Clean a weekly export with Power Query

If the same export lands in your inbox every week, Power Query lets you set the cleanup up once and replay it. Your source rows aren’t changed.

  1. Click a cell in the data and choose Data > From Table/Range. Confirm the range and the header setting.
  2. In the Power Query Editor, select the column headers that define a match (Ctrl+click for several).
  3. On the Home tab, in the Reduce Rows group, choose Remove Rows > Remove Duplicates.
  4. Click Close & Load. Next week, paste in the new data and choose Data > Refresh All.

Two differences from the Data tab command matter. Power Query compares text with case sensitivity, so “[email protected]” and “[email protected]” stay separate unless you first convert the column with Transform > Format > lowercase. And Microsoft’s Power Query documentation notes that it doesn’t guarantee which instance of a set of duplicates is kept, so sorting first isn’t a reliable way to pick the survivor there. See keeping or removing duplicate rows in Power Query and the deeper notes on working with duplicate values.

Repeats Excel can’t see

When rows look identical but Excel says there’s nothing to remove, the cells differ in a way the eye skips over.

Hidden difference Example Fix
Extra spaces “Sam Carter ” with a trailing space Helper column with =TRIM(A2), paste back as values
Nonbreaking spaces from web pages Space that TRIM leaves alone =TRIM(SUBSTITUTE(A2,CHAR(160)," "))
Line breaks or nonprinting characters Text pasted from another system =TRIM(CLEAN(A2))
Different display formats 3/8/2026 next to Mar 8, 2026 Apply one number format to the whole column
Numbers stored as text Green triangle in the cell corner Select the cells, open the warning icon, choose Convert to Number
Inconsistent capitals JORDAN LEE and Jordan Lee Make them consistent with UPPER, LOWER or PROPER

The display-format row trips people up because Microsoft states that duplicates are judged by what the cell shows, not by the underlying value. Details on the first fix are on the TRIM function page. For consistent name capitals, the steps to capitalize the first letter of each word use PROPER in a helper column. Microsoft’s Remove Duplicates pages don’t state whether the command is case-sensitive, so if capitals matter (product codes, for instance), test on the safety copy first.

If Remove Duplicates is unavailable

  • You’re still editing a cell. Press Enter or Esc so the ribbon wakes up.
  • The sheet is protected. Choose Review > Unprotect Sheet; you may need the password.
  • Several sheets are grouped. If the title bar shows Group, right-click a tab and choose Ungroup Sheets.
  • The file opened in Protected View. Click Enable Editing in the yellow bar.
  • You clicked inside a PivotTable. Clean the pivot’s source data instead, then refresh the pivot.
  • The list has subtotals or an outline. Microsoft says to remove these first: Data > Subtotal > Remove All, then Data > Ungroup > Clear Outline.

If the reported counts look too high, empty cells and cells holding only spaces may be included in them, so delete blank rows first.

Excel for Mac and Excel for the web

On a Mac (Microsoft 365, 2024 or 2021), Remove Duplicates sits on the Data tab in the Data Tools group. Check the columns to compare, then click the Remove Duplicates button in the dialog. Advanced Filter is at Data > Advanced with the same Unique records only box, as shown on Microsoft’s Mac page on how to filter for or remove duplicate values. Undo is Command+Z.

In Excel for the web, select the range, choose Data > Remove Duplicates, clear the columns that shouldn’t count and select OK; a message reports how many duplicates were removed. The browser saves changes as you go, so make the safety copy before you start. UNIQUE works in the browser. The Advanced Filter and Power Query steps above are written for the desktop app. If the data lives in Google Sheets instead, the approach is different; this walkthrough on highlighting duplicates across multiple columns in Google Sheets covers the formula route there.

Check the result and recover from a bad cleanup

  1. Compare the number in Excel’s message with the TRUE count from your flag column.
  2. Select one column and read Count on the status bar. Original rows minus removed rows should equal what’s left.
  3. Spot-check two or three people you know were repeated. Are the right addresses still there?
  4. Check totals and lookups elsewhere in the workbook. Deleted rows move the remaining rows up, so formulas pointing at fixed cells can now pick up a different record. References to a whole table or column adjust.

If anything is wrong, press Ctrl+Z before doing anything else. After the workbook closes, Undo is gone and your options are the safety copy sheet and the Removed sheet you kept. Microsoft’s find and remove duplicates page gives the same advice: copy the original data before you remove anything.

Questions people ask about duplicate rows

How do I delete every copy of a repeated value, including the first one?

Remove Duplicates always keeps one copy. To drop all of them, use a flag with a fixed range, =COUNTIF($B$2:$B$9,B2)>1, filter to TRUE and delete those rows. In current Excel, =UNIQUE(B2:B9,,TRUE) lists only the values that appear once, without touching the source.

How can I count the duplicates without deleting anything?

Compare two numbers: =ROWS(B2:B9) gives the total and =ROWS(UNIQUE(B2:B9)) gives the distinct count. The difference is the number of rows Remove Duplicates would delete with that column checked. In Excel 2019 or 2016, count the TRUE values in the flag column with =COUNTIF(E2:E9,TRUE).

Can I remove duplicates from a pivot table?

Not directly. A pivot table summarizes its source, so clean the source list, then right-click the pivot table and choose Refresh. Also note that the Duplicate Values highlight rule can’t be applied to a pivot table’s Values area.

Why did Remove Duplicates leave rows that match in every visible column?

A checked column holds values that differ between those rows, usually an ID, a timestamp, or the flag column itself. Open the dialog again and scroll the full list under Columns before clicking OK.

For a one-off cleanup, the safe order is: copy the sheet, flag the rows, sort so the right copy sits on top, remove, then check the counts. For lists that come back every week, move the work into UNIQUE or Power Query so the clean version rebuilds itself.