In this tutorial, you will learn how to show duplicates in Excel. We are going to have a close look at different methods to shade duplicate cells, entire rows, or consecutive dupes using conditional formatting. Also, you will see how to highlight duplicates with different colors using a specialized tool.
Last week, we explored different ways to identify duplicates in Excel. Undoubtedly, the duplicate formulas are very useful, but highlighting duplicate entries with a defined color could make data analysis even easier.
The fastest way to find and highlight duplicates in Excel is using conditional formatting. The biggest advantage of this method is that it not only shows you the existing dupes, but detects and colors new duplicates as you input, edit or overwrite your data.
Further on in this tutorial, you will find a number of ways to highlight duplicate records depending on your specific task. These techniques work in all versions of Excel 365, Excel 2019, Excel 2016, Excel 2013, Excel 2010 and lower.
For starters, in all Excel versions, there is a predefined rule for highlighting duplicate cells. To use this rule in your worksheets, perform the following steps:
Apart from the red fill and text formatting, a handful of other predefined formats are available in the dropdown list. To highlight duplicates using some other color, click Custom Format… (the last item in the drop-down) and select the fill and/or font color of your liking.
Tip. To highlight unique values, select Unique in the left-hand box.
Using the inbuilt rule, you can highlight duplicates in one column or in several columns as shown in the following screenshot:
Note. When applying the built-in duplicate rule to two or more columns, Excel does not compare the values in those columns, it simply highlights all duplicate instances. If you want to find and highlight matches and differences between 2 columns, you will find a few examples in the following tutorial: How to compare two columns in Excel.
When using Excel's inbuilt rule for highlighting duplicate values, please keep in mind the following two things:
To highlight 2nd and all subsequent duplicate occurrences, select the cells you want to color, and create a formula-based rule in this way:
Where A2 is the top-most cell of the selected range.
If you don't have much experience with Excel conditional formatting, you will find the detailed steps to create a formula-based rule in the following tutorial: Excel conditional formatting based on another cell value.
As the result, the duplicate cells excluding first instances will get highlighted with the color of your choosing:
To view duplicates beginning with the Nth occurrence, create a conditional formatting rule based on the formula like in the previous example, with the only difference that you replace >1 at the end of the formula with the required number. For example:
To highlight 3rd and all subsequent duplicate instances, create a conditional formatting rule based on this formula:
To highlight 4th and all subsequent duplicate records, use this formula:
To highlight only specific occurrences, use the equal to operator (=). For example, to highlight only 2nd instances, you would go with this formula:
When you want to check for duplicates over multiple columns, not by comparing the columns to each other, but find all instances of the same item in all the columns, use one of the following solutions.
If the first instance of an item that appears in the data set more than once is deemed a duplicate, the easiest way to go is use Excel's built-in rule for duplicates.
Or, create a conditional formatting rule with this formula:
For example, to highlight duplicates in the range A2:C8, the formula goes as follows:
Please notice the use of absolute cell references for the range ($A$2:$C$8), and relative references for the top cell (A2).
The solution for this scenario is a lot trickier, no wonder Excel has no built-in rule for it :)
To highlight duplicate entries in several columns ignoring the 1st occurrences, you will have to create 2 rules with the following formulas:
Here you use exactly the same formula as we used to highlight duplicates without 1st occurrences in one column (the detailed steps can be found here).
In this example, we are creating a rule for A2:A8 with this formula:
As the result, the duplicate items without 1st occurrences are highlighted in the left-most column of the range (there is only one such item in our case):
To highlight duplicates in the remaining columns (B2:C8), use this formula:
In the above formula, the first COUNTIF function counts the occurrences of a given item in the first column, and the second COUNTIF does the same for all subsequent columns. And then, you add up those numbers and check if the sum is greater than 1.
As the result, all duplicated items excluding their 1st occurrences are found and highlighted:
Another possible solution is to add an empty column to the left of your dataset, and combine the above formulas into a single formula like this:
=IF(COLUMNS($B2:B2)>1,COUNTIF(A$2:$B$8,B2),0) + COUNTIF(B$2:B2,B2)>1
Where B2 is the top cell with data in the 2nd column of the target range.
To better understand the formula, let's break it down into 2 main parts:
Because the IF condition is always TRUE for all the columns other than the first one (number of columns is greater than 1), the formula proceeds in this way:
If your table contains several columns, you may want to highlight whole rows based on duplicate records in a specific column.
As you already know, Excel's built-in rule for duplicates works only at the cell level. But a custom formula-based rule has no problem with shading rows. The key point is to select the whole rows, and then create a rule with one of the following formulas:
Where A2 is the first cell and A15 is the last used cell in the column that you want to check for duplicates. As you see, the clever use of absolute and relative cell references is what makes a difference.
The following screenshot demonstrates both rules in action:
The previous example has demonstrated how to color entire rows based on duplicate values in a specific column. But what if you want to view rows that have identical values in several columns? Or, how do you highlight absolute duplicate rows, the ones that have completely equal values in all columns?
For this, employ the COUNTIFS function that allows comparing cells by multiple criteria. For example, to highlight duplicate rows that have identical values in columns A and B, use one of the following formulas:
=COUNTIFS($A$2:$A2, $A2, $B$2:$B2, $B2)>1
=COUNTIFS($A$2:$A$15, $A2, $B$2:$B$15, $B2)>1
The following screenshot demonstrates the result:
As you understand, the above example is for demonstration purposes only. When highlighting duplicate rows in your real-life sheets, you are naturally not limited to comparing values only in 2 columns, the COUNTIFS function can process up to 127 range/criteria pairs.
Sometimes, you may not need to highlight all duplicates in a column but rather show only consecutive duplicate cells, i.e. the ones that are next to each other. To do this, select the cells with data (not including the column header) and create a conditional formatting rule with one of the following formulas:
The following screenshot demonstrates highlighting consecutive duplicate texts, but these rules will also work for consecutive duplicate numbers and dates:
If your Excel sheet may have empty rows and you don't want the consecutive blank cells to get highlighted, make the following improvements to the formulas:
=AND($A2<>"", OR($A1=$A2, $A2=$A3))
As you see, it's no big deal to highlight duplicates in Excel using conditional formatting. However, there is even a faster and easier way. To find it out, read the next section of this tutorial.
The Duplicate Remover add-in is the all-in-one solution to deal with duplicate records in Excel. It can find, highlight, select, copy or move duplicated cells or entire duplicate rows.
Despite its name, the add-in can quickly highlight duplicates in different colors without deleting them.
The Duplicate Remover adds 3 new features to your Excel Ribbon:
After installing Ultimate Suite for Excel, you will find these tools on the Ablebits Data tab in the Dedupe group:
For this example, I've created the following table with a few hundred rows. And our aim is to highlight duplicate rows that have equal values in all three columns:
Believe it or not, you can get the desired result with just 2 mouse clicks :)
Tip. If you want to detect duplicate rows by one or more columns, uncheck all irrelevant columns and leave only the key column(s) selected.
And the result would look similar to this:
As you see in the above image, the Dupe Table tool has highlighted duplicate rows without first instances.
If you want to highlight duplicates including first occurrences, or if you want to color unique records rather than dupes, or if you don't like the default red color, then use the Duplicate Remover wizard that has all these features and a lot of more.
Compared to the swift Dedupe Table tool, the Duplicate Remover wizard requires a few more clicks, but it makes up for this with a number of additional options. Let me show it to you in action:
Verify that the table has been selected correctly and click Next.
For this example, let's find Duplicates + 1st occurrences:
Additionally, the add-in lets you specify if your table has headers and if you want to skip empty cells. Both options are selected by default.
Since today we are exploring different ways to highlight duplicates in Excel, our choice is obvious :) So, select Fill with color and choose one of the standard theme colors, or click More Colors… and pick any custom RGB or HSL color.
Click the Finish button and enjoy the result :)
This is how you highlight duplicates in Excel using our Duplicate Remover add-in. If you are curious to try this tool on your own worksheets, you are most welcome to download a fully-functional trial version of the Ultimate Suite that includes all our time-saving tools for Excel. And your feedback in comments will be greatly appreciated!
Table of contents