How to Find Duplicates in Excel: The Ultimate Step-by-Step Guide
Written by the team at Iron Software. If you are looking to automate your spreadsheet tasks programmatically, be sure to visit the IronXL product page to learn more about our professional Excel library for .NET.
In the world of data management, accuracy is everything. Whether you are managing a mailing list, analyzing quarterly sales, or auditing financial records, duplicate data is the enemy. It skews your metrics, leads to double-billing, and creates general chaos in your reports.
If you are looking for the fastest way to spot these errors, the answer lies in Conditional Formatting. In the following steps, we'll look at the different approaches for how to find duplicates in Excel files.
The Quickest Way to Find Duplicates in Excel
The fastest way to find duplicates in Excel is to select your data and use the Duplicate Values tool.
- Select your data range.
-
Go to the Home tab.
-
Click Conditional Formatting > Highlight Cells Rules > Duplicate Values.
- Click OK.
For those who prefer speed, the keyboard shortcut for using these Conditional Formatting rules is Alt → H → L → H → D. This instantly triggers the duplicate detection engine, highlighting every repeated entry in your selection.
Why Finding Duplicates is Essential for Data Integrity
Before we dive into the multiple methods of identification, it is important to understand why we do this. Data redundancy often occurs during:
- Manual Data Entry: Human error is the most common cause of duplicates.
- System Exports: When merging data from multiple CRMs or legacy databases.
- Copy-Paste Actions: Accidental double-pasting into a master sheet.
Leaving these duplicates unchecked can lead to "dirty data," making your pivot tables and formulas produce incorrect results. In this guide, we will cover every possible method to find, highlight, and manage duplicates, ranging from basic ribbon tools to advanced Power Query techniques.
Method 1: Using Conditional Formatting (The Visual Approach)
This is the standard "professional" way to handle duplicates during a live audit. It doesn't delete the data; it simply applies a visual layer so you can see where the problems exist.
Step-by-Step Instructions
- Select your data: Click and drag to highlight the cells, or click a column letter (like A) to select the entire column.

- Access the Menu: On the Home tab, locate the Styles group and click Conditional Formatting.

- Apply the Rule: Hover over Highlight Cell Rules and select Duplicate Values.

-
Choose Your Style: A dialog box will appear. You can choose "Light Red Fill with Dark Red Text" (the default) or create a "Custom Format" if you want a specific color like yellow or green.
- Confirm: Click OK.
Output for Find and Highlight Duplicate Values

Why use this method?
It is non-destructive. You can see the duplicates, investigate why they are there, and decide manually whether to keep or delete them.
Method 2: The "Remove Duplicates" Tool (The Cleaning Approach)
If you already know the duplicates are garbage and you just want them gone, don't waste time highlighting them. Use the Remove Duplicates feature to strip them out in seconds.
How to use it
-
Click anywhere inside your data table.
- Go to the Data tab on the Ribbon.

- In the Data Tools group, click Remove Duplicates.
![]()
- Select Columns: A window will pop up asking which columns to check.

* For example, if you wanted to delete repeated emails, you would select only "Email," Excel will delete any row where the email is repeated.
* If you select all columns, Excel will only delete a row if _every single cell_ in that row is an exact match for another row.
- Click OK. Excel will tell you how many duplicate values were found and removed. It will also tell you how many unique values remain.

Pro Tip: Always copy your data to a new sheet before using this tool. Once the duplicates are removed and the file is saved, you cannot "un-delete" them easily if you realize later that some were legitimate entries.
Method 3: Finding Duplicates with the COUNTIF Formula
Sometimes, highlighting isn't enough. You might want a separate column that explicitly tells you how many times a value appears. For this, we use the COUNTIF function.
The Logic
The COUNTIF function counts how many times a specific value appears in a range. If that count is greater than 1, you have a duplicate.
How to Implement
- In a new column (let's say Column E), enter the following formula:
=COUNTIF(B:B, B2)
=COUNTIF(B:B, B2)
This appears to be an Excel formula rather than C# code. If you have C# code that interacts with Excel or a specific C# snippet you'd like converted, please provide that code for conversion to VB.NET.
-
Drag the formula down to the bottom of your list.
-
Interpret the Results:
- 1: This is a unique value.
- 2 or higher: This value is a duplicate.
-
Example Output: To Find Duplicate Rows or Data with the COUNTIF Formula

Advanced Formula: Highlighting Only the Second Occurrence
If you want to keep the first instance of a name but highlight any subsequent times it appears, use a "expanding range" formula:
=COUNTIF($A$2:A2, A2) > 1
=COUNTIF($A$2:A2, A2) > 1
By locking the first part of the range ($A$2) but leaving the second part relative (A2), the formula checks "from the top down to my current row." This is the best way to flag duplicates for deletion while leaving the original data untouched.
Method 4: Using Power Query for Large Datasets
If you are working with 100,000+ rows, Excel's standard formatting can make your computer lag. Power Query is a built-in data processing engine that handles massive datasets with ease.
The Power Query Workflow
-
Select your data and go to the Data tab.
-
Click From Table/Range (this will turn your data into an official Excel Table).
- Once the Power Query Editor opens, right-click the column header you want to check.
-
Select Keep Duplicates (to see only the errors) or Remove Duplicates (to clean the list).
- Click Close & Load to bring the cleaned data back into a new Excel sheet.
Method 5: Using VBA for Automated Audits
For power users who audit the same types of files every week, a VBA macro can turn a 5-minute task into a 1-second task.
The Macro Code
To use this, press Alt + F11, go to Insert > Module, and paste:
Sub HighlightAllDuplicates()
Dim myRange As Range
Set myRange = Selection
myRange.FormatConditions.AddUniqueValues
myRange.FormatConditions(myRange.FormatConditions.Count).SetFirstPriority
myRange.FormatConditions(1).DupeUnique = xlDuplicate
With myRange.FormatConditions(1).Interior
.Color = RGB(255, 199, 206) ' Light Red
End With
End Sub
Sub HighlightAllDuplicates()
Dim myRange As Range
Set myRange = Selection
myRange.FormatConditions.AddUniqueValues
myRange.FormatConditions(myRange.FormatConditions.Count).SetFirstPriority
myRange.FormatConditions(1).DupeUnique = xlDuplicate
With myRange.FormatConditions(1).Interior
.Color = RGB(255, 199, 206) ' Light Red
End With
End Sub
Option Strict On
Sub HighlightAllDuplicates()
Dim myRange As Range
myRange = Selection
myRange.FormatConditions.AddUniqueValues()
myRange.FormatConditions(myRange.FormatConditions.Count).SetFirstPriority()
myRange.FormatConditions(1).DupeUnique = xlDuplicate
With myRange.FormatConditions(1).Interior
.Color = RGB(255, 199, 206) ' Light Red
End With
End Sub
Now, you can simply select a range and run this macro to apply the red highlight instantly.
Common Issues & Troubleshooting
Even the best tools can fail if your data is "dirty." Here are the most common reasons Excel might miss a duplicate:
1. Invisible Spaces
Excel sees "Apple" and "Apple " (with a space at the end) as completely different things.
- Fix: Use the =TRIM(A2) function in a helper column to remove all leading and trailing spaces before running your duplicate check.
2. Numbers Stored as Text
If one cell is the number 123 and another is the text '123, Excel will not flag them as duplicates.
- Fix: Select the column, go to Data > Text to Columns, and click Finish. This converts everything in that column to a consistent format.
3. Non-Breaking Spaces
Data copied from websites often contains a "non-breaking space" (ASCII 160) which the TRIM function cannot remove.
- Fix: Use Find and Replace (Ctrl + H). In the "Find" box, hold Alt and type 0160 on your numpad. Leave the "Replace" box empty and click Replace All.
For Developers: Automating Duplicate Detection with IronXL
While the manual methods above are perfect for office workers, developers often need to handle duplicate detection at scale within an application. If you are building a .NET application, manually opening Excel isn't an option.
IronXL provides a robust, high-speed library for .NET developers to interact with Excel files without needing Microsoft Office installed on the server.
Why Use IronXL?
- No Interop: Avoid the headaches of Microsoft.Office.Interop.
- Manipulate Data with Ease: Easily open and edit Excel Worksheets within your projects, whether you just need to locate duplicate cells and highlight them, edit entire rows, apply formatting styles, extract unique values, or just enter new data.
- Speed: Process massive spreadsheets in milliseconds.
- C# Integration: Use familiar LINQ syntax to find and group duplicates, even if you need to highlight duplicate rows based off multiple criteria.
Code Snippet: Finding Duplicate Entries in C#
Here is how easy it is to find and highlight duplicates programmatically using IronXL:
using IronXL;
using System.Linq;
// Load the workbook
WorkBook workbook = WorkBook.Load("financial_report.xlsx");
WorkSheet sheet = workbook.DefaultWorkSheet;
// Select the column to audit (e.g., Column B - Revenue)
var range = sheet["B2:B20"];
// Use LINQ to find the duplicate values
var duplicateList = range.GroupBy(c => c.Value.ToString())
.Where(g => g.Count() > 1)
.Select(g => g.Key);
// Apply styling to those duplicates
foreach (var cell in range)
{
if (duplicateList.Contains(cell.Value.ToString()))
{
cell.Style.BackgroundColor = "#FFC7CE"; // Light Red fill
cell.Style.Font.Color = "#9C0006"; // Dark Red text
}
}
// Save the audited file
workbook.SaveAs("Audited_financial_report.xlsx");
using IronXL;
using System.Linq;
// Load the workbook
WorkBook workbook = WorkBook.Load("financial_report.xlsx");
WorkSheet sheet = workbook.DefaultWorkSheet;
// Select the column to audit (e.g., Column B - Revenue)
var range = sheet["B2:B20"];
// Use LINQ to find the duplicate values
var duplicateList = range.GroupBy(c => c.Value.ToString())
.Where(g => g.Count() > 1)
.Select(g => g.Key);
// Apply styling to those duplicates
foreach (var cell in range)
{
if (duplicateList.Contains(cell.Value.ToString()))
{
cell.Style.BackgroundColor = "#FFC7CE"; // Light Red fill
cell.Style.Font.Color = "#9C0006"; // Dark Red text
}
}
// Save the audited file
workbook.SaveAs("Audited_financial_report.xlsx");
Imports IronXL
Imports System.Linq
' Load the workbook
Dim workbook As WorkBook = WorkBook.Load("financial_report.xlsx")
Dim sheet As WorkSheet = workbook.DefaultWorkSheet
' Select the column to audit (e.g., Column B - Revenue)
Dim range = sheet("B2:B20")
' Use LINQ to find the duplicate values
Dim duplicateList = range.GroupBy(Function(c) c.Value.ToString()) _
.Where(Function(g) g.Count() > 1) _
.Select(Function(g) g.Key)
' Apply styling to those duplicates
For Each cell In range
If duplicateList.Contains(cell.Value.ToString()) Then
cell.Style.BackgroundColor = "#FFC7CE" ' Light Red fill
cell.Style.Font.Color = "#9C0006" ' Dark Red text
End If
Next
' Save the audited file
workbook.SaveAs("Audited_financial_report.xlsx")
Output Highlighting Duplicate Values within the Selected Range

Comparison of Methods
| Method | Best For | Difficulty | | --- | --- | --- | | Conditional Formatting | Quick visual audits of small/medium lists. | Beginner | | Remove Duplicates | Permanent cleaning of data. | Beginner | | COUNTIF Formula | Adding logic to your sheet (e.g., "if count > 3"). | Intermediate | | Power Query | Very large datasets or recurring data imports. | Advanced | | IronXL (.NET) | Building apps or automated server-side reports. | Developer |
Summary and Best Practices
Finding duplicates in Microsoft Excel files is more than just a formatting trick; it’s a critical step in professional data analysis. To stay ahead of errors:
-
Always keep a backup before using "Remove Duplicates."
-
Clean your data first using TRIM and CLEAN to ensure spaces don't hide duplicates.
- Use visual cues while you work to catch errors in real-time.
Whether you are a business professional using the Ribbon or a developer using IronXL, having a strategy for data deduplication will ensure your reports remain accurate and your databases stay lean.
Ready to automate your Excel workflows? Check out the IronXL free trial and start processing spreadsheets like a pro today.




