Duplicate rows creep into every spreadsheet: a CSV export runs twice, a colleague pastes the same orders again, or two lists are merged without checking. This guide shows how to remove duplicates in Excel five different ways, from the one-click Remove Duplicates tool to a formula that never touches your source data. It also covers the same job in Google Sheets and LibreOffice Calc.
All examples use one small orders table, and a free practice workbook with the same data is attached to this post.
The sample data
The table sits in A5:D17 with the headers Order ID, Customer, City and Amount. Rows 6 to 17 hold 12 orders. Three of them are exact copies (ORD-101, ORD-102 and ORD-104 each appear twice), so the clean list should have 9 rows. Some customers also have several genuine orders, which matters when you decide what “duplicate” means.
| Order ID | Customer | City | Amount |
|---|---|---|---|
| ORD-101 | Asha Rao | Pune | 1200 |
| ORD-102 | Ben Clark | Leeds | 850 |
| ORD-103 | Chen Li | Austin | 430 |
| ORD-101 | Asha Rao | Pune | 1200 |
| … | … | … | … |
Method 1: Remove duplicates in Excel with the built-in tool
- Click any cell inside the table (or select the range).
- Go to Data > Data Tools > Remove Duplicates.
- Tick My data has headers, then choose the columns to compare.
- Click OK. Excel reports how many duplicates were removed and how many unique values remain.
The column choice is the key decision. With all four columns ticked, Excel removes only the three exact copies. If you tick only Customer, Excel keeps the first row for each customer and deletes every other row, including real orders. Microsoft’s guide to filtering for unique values or removing duplicates confirms that the whole row is deleted, even for columns you did not tick, and that the first occurrence is always kept.
This tool deletes data permanently, so copy the sheet first. Press Ctrl+Z straight away if the result looks wrong. It also refuses to work on outlined or subtotaled data until you remove the outline and subtotals.
Method 2: Get a clean list with UNIQUE
If you want to keep the original data, use the UNIQUE function in Excel for Microsoft 365, Excel for the web, Excel 2021 and Excel 2024. It returns a de-duplicated copy that updates when the source changes.
=UNIQUE(array, [by_col], [exactly_once])
| Goal | Formula | Result with the sample data |
|---|---|---|
| Remove duplicate rows | =UNIQUE(A6:D17) | 9 rows (3 copies dropped) |
| Distinct customers | =UNIQUE(B6:B17) | 6 names |
| Customers who ordered only once | =UNIQUE(B6:B17,,TRUE) | Emma Wolf, Farah Khan |
| Count unique order IDs | =COUNTA(UNIQUE(A6:A17)) | 9 |
| Distinct customers A to Z | =SORT(UNIQUE(B6:B17)) | 6 names, sorted |
Leave enough empty cells below the formula, or you will see #SPILL!. To keep only the rows that match a condition as well, wrap the result in FILTER; our FILTER function guide shows how.
Method 3: Flag duplicates with COUNTIF before deleting
Sometimes you need to review duplicates rather than delete them. Add a helper column in E6 and fill it down to E17:
=IF(COUNTIF($A$6:A6,A6)>1,"Duplicate","First")
The range grows as you fill down, so the first ORD-101 says “First” and the second says “Duplicate”. With the sample data, rows 9, 12 and 16 are flagged. Now you can filter the column, check each flagged row, and delete only the ones you are sure about. This formula works in every version of Excel, Google Sheets and LibreOffice Calc.
Method 4: Highlight duplicates with conditional formatting
Select A6:A17, then go to Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values. Every repeated order ID is coloured, including the first copy. That is a fast visual check, but it compares one column at a time. For more rule ideas, see our post on conditional formatting in Excel.
Method 5: Advanced Filter for unique records
Older Excel versions without UNIQUE can still copy a clean list. Select the table, choose Data > Sort & Filter > Advanced, pick Copy to another location, enter a target cell, and tick Unique records only. The source stays untouched, but the copy does not update automatically.
Remove duplicates in Google Sheets
Google Sheets has its own tool under Data > Data cleanup > Remove duplicates. Choose the columns to analyse, tick “Data has header row”, and click Remove duplicates. Google’s help page on removing duplicates and trimming whitespace notes one important difference: cells with the same values but different letter case, formatting or formulas still count as duplicates.
The formula route is the same as in Excel. =UNIQUE(A6:D17) works, and Sheets also accepts the by_column and exactly_once arguments, so =UNIQUE(B6:B17, FALSE, TRUE) returns customers who appear only once. Before removing duplicates, run Data > Data cleanup > Trim whitespace. A trailing space makes “Asha Rao ” look different from “Asha Rao”.
Remove duplicates in LibreOffice Calc
LibreOffice 25.2 added a Data > Duplicates dialog (Handle Duplicate Records). You choose to compare rows or columns, say whether the range has headers, pick the fields to compare, and then either select or remove the duplicates. On older versions, use Data > More Filters > Standard Filter and tick No duplications under Options.
Calc has supported UNIQUE since version 24.8. It uses semicolons between arguments: =UNIQUE(A6:D17) or =UNIQUE(B6:B17;FALSE();TRUE()). The help page still suggests entering it as an array formula with Ctrl+Shift+Enter.
Which method should you use?
| Method | Changes source? | Updates automatically? | Where it works |
|---|---|---|---|
| Remove Duplicates tool | Yes, deletes rows | No | Excel; Sheets (Data cleanup); Calc 25.2+ (Duplicates) |
| UNIQUE | No | Yes | Excel 2021+ / 365; Google Sheets; Calc 24.8+ |
| COUNTIF flag | No | Yes | All three apps, all versions |
| Conditional formatting | No | Yes | All three apps |
| Advanced / Standard Filter | No (copy) | No | Excel; Calc |
Common problems
- “Duplicates” survive: hidden spaces or non-breaking spaces differ. Clean them with TRIM (or Trim whitespace in Sheets) first.
- Dates not matched in Excel: Microsoft notes that the comparison uses what appears in the cell, so the same date shown in two formats can be treated as unique. Apply one date format first.
- Too many rows deleted: you compared too few columns. Undo and tick every column that defines a real duplicate.
- #NAME? with UNIQUE: your Excel version is older than 2021, or your Calc is older than 24.8. Use the COUNTIF flag or Advanced Filter instead.
FAQ
Does Remove Duplicates keep the first or the last row?
The first. Excel keeps the first occurrence and deletes the later copies. To keep the latest row, sort the data newest-first before running the tool.
Can I remove duplicates without deleting data?
Yes. Use =UNIQUE(range) on another sheet, or Advanced Filter with “Copy to another location”. Both leave the source table unchanged.
How do I count unique values in Excel?
Use =COUNTA(UNIQUE(A6:A17)). With the sample data, it returns 9 distinct order IDs out of 12 rows.
Download the companion practice workbook below to try all five methods on the same orders table. Then compare your answers with the Solutions sheet.
Download the practice workbook
The same data as this tutorial, with empty answer cells and a Solutions sheet.