To remove duplicates in Excel, select your complete data table, open the Data tab, and choose Remove Duplicates. Select the columns that define a duplicate record, then confirm. Excel keeps the first matching record and removes subsequent matches from the selected data.
If you need to review duplicates without deleting them, use conditional formatting or COUNTIF first. If you want a separate, automatically updated list, use UNIQUE. For repeated imports from multiple files, use Power Query. This guide shows how to choose the right method without accidentally deleting legitimate records.
In this guide
- Which method should you use?
- Before deleting anything: define what a duplicate means
- 1. Remove duplicates using Excel’s built-in tool
- 2. Highlight duplicate values without deleting them
- 3. Find duplicates with COUNTIF and COUNTIFS
- 4. Extract a unique list with the UNIQUE formula
- 5. Remove duplicate records automatically with Power Query
- Why Excel may not identify duplicates as expected
- Frequently asked questions
- Related guides
Which method should you use?
| Method | Best use | Changes original data? |
|---|---|---|
| Remove Duplicates | One-time cleanup of confirmed duplicate records | Yes |
| Conditional Formatting | Visually identify repeated values | No |
| COUNTIF / COUNTIFS | Flag repeated values or combinations for review | No |
| UNIQUE | Create a separate dynamic list | No |
| Power Query | Repeatable data cleanup during imports | No, when loaded separately |
Before deleting anything: define what a duplicate means
A repeated customer name, product, or amount does not necessarily mean a transaction was entered twice. Use the actual business rule for your dataset. An invoice ID may identify an invoice, while an invoice ID plus line number may identify an individual invoice item.
Consider this fictional invoice register, with headers in row 1 and data in A2:D6:
| Invoice ID | Customer | Item | Amount |
|---|---|---|---|
| INV-101 | North Office | Printer | 250 |
| INV-102 | North Office | Toner | 80 |
| INV-102 | North Office | Toner | 80 |
| INV-103 | West Office | Toner | 80 |
| INV-104 | North Office | Printer | 250 |
The second INV-102 row appears to be a duplicate. Confirm it against the underlying invoice before deleting it. The two printer sales and the other toner sale are separate transactions. If INV-102 is confirmed as a duplicate, the original five rows total 740 and the cleaned four rows total 660. Deleting all repeated amounts or customer names would give an incorrect result.
1. Remove duplicates using Excel’s built-in tool
Use this approach when your records have already been reviewed and you want to permanently remove repeated entries from the selected range.
- Save a backup copy of the workbook or duplicate the worksheet.
- Select the entire table, including every related column and the header row.
- Go to Data and select Remove Duplicates, usually under Data Tools.
- Confirm the header setting. Select only the columns that define a duplicate for your dataset. In the example, select Invoice ID if every invoice is meant to appear exactly once.
- Confirm and inspect Excel’s summary of deleted and remaining records. Recheck your row count and totals before saving.
For a full-row match, select all relevant fields in the dialog. For matching by two fields, select both. Excel compares the selected values as a combined key, then removes the matching record within the selected data, not just the contents of the key column.
This is why selecting the complete table matters. Selecting only a narrow column can leave the other fields outside the operation and disrupt the relationship between cells. The Microsoft duplicate removal guide explains the built-in feature. Use Undo immediately if the result is wrong.
2. Highlight duplicate values without deleting them
Conditional formatting is a useful first check when you do not yet know which repeated records should be removed.
- Select the column containing the identifiers, such as A2:A6.
- On the Home tab, open Conditional Formatting.
- Choose Highlight Cells Rules and then Duplicate Values.
- Select a highlight style and confirm.
- Inspect the flagged cells and compare the corresponding records against your source documents.
In the invoice example, both INV-102 cells are highlighted. The formatting does not decide which one to keep. For multiple-column matching, use a COUNTIFS helper column rather than assuming a repeated single field identifies a duplicate transaction.
3. Find duplicates with COUNTIF and COUNTIFS
A helper column makes duplicates easier to filter, investigate, and document. Enter the following formula in E2 and copy it down to E6:
=IF(COUNTIF($A$2:$A$6,A2)>1,"Review","")
Both INV-102 records will show Review. If you want to mark only the second and later appearances of each invoice ID, use an expanding range instead:
=IF(COUNTIF($A$2:A2,A2)>1,"Repeated","")
Only the third data row (worksheet row 4) is marked Repeated in the example. The formula assumes the current row order represents the order you want to keep. If the preferred record is the most recently updated one, sort and verify your data before using that assumption.
To identify repeated combinations of an invoice ID and item name, try:
=IF(COUNTIFS($A$2:$A$6,A2,$C$2:$C$6,C2)>1,"Review","")
This still needs a business rule: one invoice may legitimately contain two lines for the same item. A reliable line identifier is preferable if one exists. Formula argument separators may be semicolons instead of commas in some regional Excel settings.
4. Extract a unique list with the UNIQUE formula
In supported versions of Excel, UNIQUE returns distinct values into a separate range. It is available in Microsoft 365 and modern releases including Excel 2021 and 2024. Enter the formula in a blank area outside the source table:
=UNIQUE(A2:A6)
The result contains INV-101, INV-102, INV-103 and INV-104. To extract distinct full rows instead of invoice IDs, use:
=UNIQUE(A2:D6)
In this example, the result contains four rows. If two records share the same invoice ID but their other fields differ, both can remain because the complete rows are not identical.
To return only invoice IDs that occur exactly once, use the optional third argument:
=UNIQUE(A2:A6,FALSE,TRUE)
That returns INV-101, INV-103 and INV-104, excluding both appearances of INV-102. This is different from keeping one copy of every distinct value. Refer to Microsoft’s UNIQUE function reference for supported versions and argument behavior. Leave enough empty cells for the formula output; an obstruction can cause a #SPILL! error.
5. Remove duplicate records automatically with Power Query
Power Query is helpful when you regularly import files that may contain repeated entries. Rather than altering the source workbooks, create a separate query result that repeats your cleaning steps when refreshed.
- Select a cell in your source table and use Data > From Table/Range in a supported desktop Excel version.
- In Power Query Editor, verify data types and inspect the columns that identify each record.
- Select the required comparison column or columns.
- Use the Remove Rows menu to remove duplicates, or keep duplicates first if you want to investigate them.
- Review the resulting rows and load the query into a separate worksheet.
Power Query compares text case-sensitively. If capitalization should not distinguish records, normalize the relevant text column first. Also, Power Query does not guarantee which duplicate row survives. If two matching keys contain different dates or amounts, do not assume sorting alone will reliably keep the newest row. Group by the key and apply an explicit date or other tie-breaking rule instead.
Microsoft explains these behaviors in Working with duplicate values and the Table.Distinct reference. Check the output again after refreshing with new source files.
Why Excel may not identify duplicates as expected
| Problem | What to check |
|---|---|
| Extra spaces in text | Use a separate helper column with TRIM and review the result. |
| Hidden characters | Inspect imported text; CLEAN can remove some nonprinting characters, but not all Unicode whitespace. |
| Leading zeros in IDs | Preserve identifiers as text if zeros are significant. |
| Same invoice, different line items | Include a line identifier in the comparison. |
| Dates appear identical but have different times | Review underlying date-time values and decide whether time matters. |
| Case differences in Power Query | Normalize capitalization only when appropriate for the data. |
For example, =TRIM(A2) can help normalize ordinary spaces in imported text. It does not remove all possible whitespace, and normalization may alter meaningful identifiers. Keep the original values while testing the cleaned version.
Frequently asked questions
Can I remove duplicates without losing the original data?
Yes. Use UNIQUE in a separate blank range, load a cleaned Power Query result into another worksheet, or work on a copy of the original sheet.
Does Excel keep the first or last duplicate?
The built-in Remove Duplicates tool retains the first occurrence in the selected data. Power Query is different: do not rely on it to retain a particular record without an explicit selection rule.
Can I remove duplicates from multiple columns?
Yes. Select your entire table and choose the comparison columns in Remove Duplicates. All selected comparison values together define the matching key.
Why are some repeated values legitimate?
Customers, products and prices can recur across separate transactions. Only remove a repeated record when the business identifier and the supporting data establish that it is genuinely duplicated.
If your duplicates originate in monthly source workbooks, combine your files in a controlled import process first. Explore our Software & Apps guides for spreadsheet workflows.
Related guides
Editorial note: The sample invoice data and calculations are original illustrative examples. The instructions follow Microsoft documentation; individual Excel builds and workbook configurations may differ. The steps have not been independently tested in every supported edition.
