How to Remove Duplicates in Excel and Keep the Latest Row
Remove duplicates in Excel without losing the newest data: sort first, use MAXIFS and FILTER, or Group By in Power Query. Works in Google Sheets too.
- Excel
- Data Quality
- Power Query

On this page
- How do you remove duplicates in Excel?
- Which row does Remove Duplicates keep?
- How do you remove duplicates and keep the most recent row?
- How do you keep the latest row with a formula?
- How do you keep the latest row in Power Query?
- How do you find duplicates before you delete them?
- How do you do this in Google Sheets?
- Where does Glow Reports fit?
- Common questions
A CRM or billing export often holds one row per update, so the same customer shows up three times with three different plans. You run Remove Duplicates on the customer column and the totals drop, but now they are wrong. Excel kept each customer's oldest row. The fix is to decide which row should survive before you delete anything: sort the newest rows to the top, then remove duplicates on the ID column only. This guide shows that method, a formula version that deletes nothing, a Power Query version you can refresh, and the same steps in Google Sheets.
How do you remove duplicates in Excel?
Select a cell in the data, then go to DataData ToolsRemove Duplicates. Tick the columns that define a duplicate and select OK. Excel deletes every later copy and tells you how many rows it removed and how many unique values remain.
The column choice matters more than the button. With every column ticked, Excel removes only rows that match on every value. With one column ticked, such as Customer, Excel keeps one row per customer, and the other columns of the rows it deletes go with them. Microsoft states that data is removed from all columns, even the ones you don't tick Microsoft Support.
The deletion is permanent once you save. Microsoft advises copying the original range to another sheet or workbook first. Do that, or work on a copy of the export. Remove Duplicates also refuses data with subtotals or an outline, so remove those before you start.
Here is the sample used in the rest of this guide, a subscription export with one row per change. Type it in A1:D9.
| Customer | Updated | Plan | MRR |
|---|---|---|---|
| C-001 | 2026-09-03 | Starter | 49 |
| C-002 | 2026-09-10 | Pro | 149 |
| C-001 | 2026-10-02 | Pro | 149 |
| C-003 | 2026-10-05 | Starter | 49 |
| C-002 | 2026-10-20 | Business | 399 |
| C-001 | 2026-11-04 | Pro | 149 |
| C-003 | 2026-11-12 | Cancelled | 0 |
| C-004 | 2026-11-15 | Starter | 49 |
Four customers, eight rows. Summing the MRR column as it stands double counts every change.
993 in MRR from the raw export, against 597 once each customer keeps only their latest row.
Which row does Remove Duplicates keep?
The first one. Microsoft documents that the first occurrence of the value in the list is kept and the other identical values are deleted. "First" means the row nearest the top of the range, whatever its date.
Exports usually list changes oldest first, as in the sample. Remove Duplicates on Customer then keeps C-001 on Starter at 49, C-002 on Pro at 149 and C-003 on Starter at 49. The total MRR reads 296, less than half the right figure, and C-003 still looks like a paying customer although they cancelled on 12 November. No error appears. The sheet looks clean and the report is wrong.
How do you remove duplicates and keep the most recent row?
Sort the newest rows to the top first, then remove duplicates on the ID column alone. Because Excel keeps the first row it meets for each ID, it keeps the latest one.
The steps on the sample:
- Check that the date column holds real dates. should return TRUE. A date stored as text sorts as text, and the text to date guide fixes it.
- Select the table and open DataSort. Sort by Customer, A to Z, then add a level for Updated, Newest to Oldest.
- Open DataData ToolsRemove Duplicates, select Unselect All, tick Customer only, and select OK.
Excel removes 4 rows and keeps 4. C-001 keeps its Pro row from 4 November, C-002 its Business row, C-003 its Cancelled row and C-004 its only row. The MRR column now sums to 597.
Sorting by Customer first is optional for the result. It makes the check easier, because each customer's rows sit together with the newest on top. When two rows share the same customer and the same date, the order between them is a coin toss. Add the time or an event number as a third sort level if the export has one.
How do you keep the latest row with a formula?
Flag each row that holds its customer's latest date with MAXIFS, then filter on the flag. Nothing gets deleted, and the flag updates when you paste a new export below. Put this in E2 and fill it down:
=B2=MAXIFS($B$2:$B$9,$A$2:$A$9,A2)MAXIFS returns the largest value in a range among the cells that meet a condition Microsoft Support. Here it finds the latest date for the customer in column A, and the comparison returns TRUE when the row's own date matches it. In the sample, rows 6 to 9 return TRUE and rows 2 to 5 return FALSE.
From there you have two options. Filter column E on TRUE and copy the visible rows to a new sheet. Or, in Excel 365, spill the clean table in one formula with FILTER, which returns the rows of a range that meet a condition Microsoft Support:
=FILTER(A2:D9,E2:E9)Two rows with the same customer and the same latest date both return TRUE. Count them with . Any result above 1 needs a closer look before the report goes out. To count how many distinct customers you should end up with, the count unique values guide has the formula.
How do you keep the latest row in Power Query?
Group the rows by customer with the All rows operation, then pull out the row with the latest date with Table.Max. This works every time you refresh, on any number of files. Microsoft's own Group by guide uses the same pattern to find the top row of each group Microsoft Learn.
- Load the export with DataFrom Table/Range or from a folder.
- Select the Customer column, then HomeGroup By. Name the new column Rows and pick the operation All rows.
- Add a custom column with Add ColumnCustom Column and the formula . Each cell now holds the record of that customer's latest row.
- Expand the new column, tick Updated, Plan and MRR, then remove the Rows column and load the result.
Watch for the shortcut many people try first: sort by date descending in Power Query, then Remove Duplicates. Power Query doesn't always keep the sort order in memory, so the step can keep an older row. On Microsoft Tech Community, a user who merged weekly files hit exactly this, and the fix was to wrap the sorted table in Table.Buffer or to add an index column before removing duplicates Microsoft Tech Community. Group By with Table.Max avoids the question. If your exports arrive as several files, the Power Query merge guide covers the folder step.
How do you find duplicates before you delete them?
Color them first, then count them. HomeConditional FormattingHighlight Cells RulesDuplicate Values colors every value that appears more than once in the selection. Run it on the Customer column to see which customers repeat.
For a number per row, add next to the data. It returns 3 for each C-001 row, 2 for C-002 and C-003, and 1 for C-004. Sort on it to put the repeats together. When the duplicates come from two files that should not overlap, the compare two columns guide finds the values present in both.
A duplicate that Excel misses is often a near duplicate: a trailing space, a non-breaking space from a web export, or a code with and without its leading zero. Each one makes two different values. Run TRIM on the ID column first. The data cleaning guide lists the other fixes in order.
How do you do this in Google Sheets?
Use the same two steps. Sort with DataSort range, newest first, then DataData cleanupRemove duplicates and tick the ID column only Google Docs Editors Help. Google treats cells with identical values as duplicates even when their letter case, formatting or formulas differ, so "C-001" and "c-001" count as one.
The MAXIFS flag and the FILTER formula work in Google Sheets with the same arguments, so you can keep the source data intact and build the clean table beside it.
Where does Glow Reports fit?
The steps above clean one export. The work comes back each month: a new file, the sort to redo, the same customers to check, and a report to rebuild from the cleaned rows.
With Glow Reports, you upload the CSV or Excel file and ask in plain language, for example the MRR by plan using each customer's latest row. The AI writes the SQL, builds the charts and drafts the text. The SQL sits under each figure, so you can see how the latest row was picked and what happens when two rows share a date, and edit the query if your rule differs. Reports export to PDF and stay in the workspace. The free plan gives 300 credits once, and a report costs 100 credits.
Common questions
Does Remove Duplicates keep the first or the last row?
The first. Excel keeps the row nearest the top of the range for each duplicate and deletes the rest. Sort the rows you want to keep to the top before you run it.
Can I undo Remove Duplicates?
Yes, with Ctrl+Z, until you save and close the file. After that the rows are gone. Copy the data to another sheet before you start.
How do I remove duplicates based on one column but keep the other columns?
Tick only that column in the Remove Duplicates dialog. Excel compares that column alone and deletes the whole row of each later copy, so the row it keeps stays complete.
Why does Remove Duplicates leave rows that look identical?
The values differ in a way you can't see, such as a trailing space, a non-breaking space from a web export, or a number stored as text in one row. Clean the column with TRIM and convert the types, then run it again.
I am a product engineer and the founder of Glow Reports. I spent more than 6 years building products in tech, data and cybersecurity, for large groups, startups and SMEs. In most organizations I saw data treated as a technical topic, when it drives business decisions. I built the reporting tool I was looking for, so the people who run small and mid-sized organizations can read their own numbers without a data team.
More from El Mehdi BenaneUpload your CRM or billing export to Glow Reports and ask for the report on each customer's latest row, with the SQL behind each figure.


