How to Find and Highlight Duplicates in Excel (Step-by-Step Guide)
Duplicate entries in Excel can lead to incorrect calculations, inaccurate reports and unnecessary confusion. Whether you are managing employee records, customer information, invoices or inventory, identifying repeated values is an important part of maintaining accurate spreadsheet data.
In this guide, you will learn how to find and highlight duplicates in Excel without deleting your original data, using conditional formatting and simple Excel formulas.
1. Sample Data for Practice
Create a new Excel worksheet and enter the following sample data, starting in cell A1.
| Employee ID | Employee Name | Department |
|---|---|---|
| E001 | James | Sales |
| E002 | Emma | Finance |
| E003 | Oliver | IT |
| E002 | Emma | Finance |
| E004 | Sophia | HR |
| E005 | William | Sales |
| E005 | William | Sales |
In this example, employee IDs E002 and E005 appear twice. We will use these records to demonstrate different methods of identifying duplicates.
2. Highlight Duplicates Using Conditional Formatting
Conditional formatting is a quick way to identify duplicate values without using formulas.
- Select cells A2:A8.
- Open the Home tab in Excel.
- Click Conditional Formatting.
- Open Highlight Cells Rules and select Duplicate Values.
- Choose your preferred highlight colour.
- Confirm the rule by clicking OK.
Excel will highlight both occurrences of E002 and E005. The other employee IDs will remain unchanged.
Tip: This method changes the appearance of your data, not the underlying values.
3. Find Duplicates Using the COUNTIF Formula
If you want a separate column that identifies duplicates, the COUNTIF function provides a useful alternative.
Enter the heading "Status" in cell D1. In cell D2, enter the following formula:
=IF(COUNTIF($A$2:$A$8,A2)>1,"Duplicate","Unique")
Copy the formula down to cell D8.
The COUNTIF function counts how many times the employee ID appears in the selected range. If it appears more than once, the formula returns Duplicate. Otherwise, it returns Unique.
Expected Results
| Employee ID | Occurrences | Status |
|---|---|---|
| E001 | 1 | Unique |
| E002 | 2 | Duplicate |
| E003 | 1 | Unique |
| E002 | 2 | Duplicate |
| E004 | 1 | Unique |
| E005 | 2 | Duplicate |
| E005 | 2 | Duplicate |
4. Identify Only the Second and Subsequent Occurrences
Sometimes you need to keep the first occurrence of a value and identify only the repeated entries that appear afterwards.
Use this formula in cell D2 and copy it down:
=IF(COUNTIF($A$2:A2,A2)>1,"Duplicate","First occurrence")
Unlike the previous formula, this version uses an expanding range. Only the second occurrence of E002 and the second occurrence of E005 will be marked as duplicates.
This approach is particularly useful when preparing records for data cleaning.
5. Highlight Entire Rows Containing Duplicate IDs
Highlighting an entire row makes duplicate records easier to review in larger spreadsheets.
- Select the data range A2:C8.
- Open Conditional Formatting from the Home tab.
- Create a New Rule.
- Choose the option to use a formula to determine which cells to format.
- Enter the formula below.
- Select a fill colour and save the rule.
=AND($A2<>"",COUNTIF($A$2:$A$8,$A2)>1)
The formula checks the employee ID in column A. When an ID appears more than once, Excel applies the selected formatting to the corresponding row across columns A to C.
The additional condition excludes empty employee ID cells.
6. Compare the Different Methods
| Method | Best Used For |
|---|---|
| Duplicate Values rule | Quick visual identification |
| COUNTIF formula | Creating a duplicate status column |
| Expanding COUNTIF range | Identifying repeat occurrences only |
| Formula-based conditional formatting | Highlighting entire records |
7. Common Duplicate Detection Problems
Extra spaces in cells
Text values containing unwanted spaces may not match as expected. Create a helper column and use the TRIM function to clean ordinary extra spaces before checking for duplicates.
=TRIM(A2)
Incorrect cell references
Ensure that the COUNTIF comparison range remains fixed when copying your formula. Dollar signs in references such as $A$2:$A$8 prevent the range from shifting.
Blank cells
Use an additional condition when you want to exclude blank cells from duplicate detection.
=IF(A2="","",IF(COUNTIF($A$2:$A$8,A2)>1,"Duplicate","Unique"))
Incorrect comparison column
Repeated employee names are not necessarily duplicate records. Two different employees may have the same name. Use an appropriate unique identifier, such as an employee ID or invoice number, when reviewing records.
8. Frequently Asked Questions
Can I highlight duplicates without deleting them?
Yes. Conditional formatting highlights repeated values while preserving the original spreadsheet data.
Does Excel COUNTIF distinguish uppercase and lowercase letters?
No. COUNTIF is not case-sensitive. For example, "APPLE" and "apple" are normally treated as matching values.
Can I highlight duplicates in Excel 2016 and Microsoft 365?
Yes. The desktop conditional formatting and COUNTIF methods described in this guide are available in Excel 2016 and newer desktop versions, including Microsoft 365. Menu layouts may vary by version and platform.
What is the difference between highlighting and removing duplicates?
Highlighting identifies repeated data without deleting it. Removing duplicates deletes entries from the selected data range according to the columns you choose. Always review and back up important records before removing them.
Conclusion
Finding duplicates in Excel is an essential spreadsheet skill. Conditional formatting is suitable for quick visual checks, while COUNTIF formulas provide greater control over how repeated entries are identified.
Choose the method that matches your requirements and review duplicate records before making permanent changes to your data.
Official References
- Microsoft Support: Find and remove duplicates
- Microsoft Support: Conditional formatting in Excel
- Microsoft Support: COUNTIF function
SheetSmart Guide — Work Smarter. Save Time. Learn More.
Comments
Post a Comment