How to Compare Two Columns and Highlight Duplicate Values in Excel

Suppose we have two lists, list A contains some products serial numbers, list B also contains some products serial numbers, and some of them are found in list A as well. So, there are some duplicate values in list A and list B. If we want to find them out, we can though compare the two list to find out the duplicate values. Actually, in our work we often meet the situations that we need to compare two lists and find out the duplicate values. In this tutorial, we will help you to fix this issue by two ways, the first one, we can use Conditional Formatting function in excel; the second one, we can use formulas.

Precondition:

Prepare two columns. Column A and column B list product serial number. There are some duplicate values.

Compare Two Columns and Highlight Duplicate Values 1

Method 1: Compare Two Columns and Highlight Duplicate Values by Conditional Formatting Function


Step 1: Select List A and List B.

Step 2: Click Home in ribbon, click Conditional Formatting in Styles group.

Compare Two Columns and Highlight Duplicate Values 2

Step 3: In Conditional Formatting dropdown list, select Highlight Cells Rules->Duplicate Values.

Compare Two Columns and Highlight Duplicate Values 3

Step 4: In Duplicate Values dialog, select Duplicate in dropdown list. Keep default value in values with dropdown list. Then click OK.

Compare Two Columns and Highlight Duplicate Values 4

Step 5: Verify that all duplicate values in both column A and column B are marked with dark red properly.

Compare Two Columns and Highlight Duplicate Values 5

Method 2: Compare Two Columns and Highlight Duplicate Values by Formulas


Step 1: Insert a new column between column A and column B. Then in B2, enter the formula =ISNA(VLOOKUP(A2,$C$2:$C$12,1,FALSE)). Click Enter, and we get FALSE.

In this formula, we can through VLOOKUP function to know whether value in column A exists in column B, if yes, VLOOKUP function will return matching value, otherwise it will return blank value, then we can use ISNA function (check whether a value is N/A) to get TRUE or FALSE value finally.

Compare Two Columns and Highlight Duplicate Values 6

Step 2: Drag the fill handle down. Verify that B3:B12 are filled with TRUE or FALSE accordingly.

Compare Two Columns and Highlight Duplicate Values 7

Step 3: Create a filter on column B. Click Data in ribbon, select Filter in Sort & Filter group.

Compare Two Columns and Highlight Duplicate Values 8

Step 4: Click filter arrow in B1. Only check on FALSE, click OK.

Compare Two Columns and Highlight Duplicate Values 9

Step 5: After above settings, duplicate values are filtered. Fill them with yellow.

Compare Two Columns and Highlight Duplicate Values 10

Step 6: Clear column B, then in B2 enter the formula =ISNA(VLOOKUP(C2,$A$2:$A$12,1,FALSE)).

Compare Two Columns and Highlight Duplicate Values 11

Step 7: Repeat above steps#2-#5 to highlight duplicate values in column C.

Compare Two Columns and Highlight Duplicate Values 12

Step 8: Clear filter in column B. And delete column B. Verify that all duplicate values are highlighted.

Compare Two Columns and Highlight Duplicate Values 13

Comment:

We can also use COUNTIF function here. Enter =COUNTIF($C$2:$C$12,A2) in B1, then we can get 1 for duplicate values or 0 for unique values.

Compare Two Columns and Highlight Duplicate Values 14

             

 

Related Posts

Filter And Transpose Data From Horizontal To Vertical
filter and transpose horizontal to vertical1

This post will show you how to use Filter function and in combination with Transpose function to filter data from horizontal and transpose data as vertical in Microsoft Excel. You can refer to the below general formula based on TRANSPOSE ...

VLOOKUP Formula | Faster Trick with 2 VLOOKUPS
Faster VLOOKUP with 2 VLOOKUPS1

This post will guide you how to use 2 VLOOKUPS function to looking up data entries from a given range of cells in Microsoft Excel. VLOOKUP with 2 lookups can be faster than a single VLOOKUP in certain scenarios. The ...

Extract Unique Items From A List
Extract Unique Items From A List In Excel1

This post will guide you how to extract unique itmes from a given list in Microsoft Excel. How to create a newly formula to get unique values from a range cells in Excel. The unique list of items is the ...

Extract substring In Excel
Extract substring In Excel1

This post will guide you how to use Excel's MID function is a quick and easy way to extract pieces from your text. Use the Excel formula to extract a substring with MID. Note: If you want to extract just ...

How to Use 3D SUM Multiple Worksheets
3D sum multiple worksheets1

To sum a range of numbers is straightforward for most Excel users, but do you know how to establish a 3D reference to total the same range of numerous sheets. In this post, I will present the steps for this ...

Extract all the matches with helper Column
how to extract all matches with helper column1

With Excel's powerful functions IF, INDEX, and MATCH, we can find exactly what you're looking for with a few clicks of the mouse. This step-by-step tutorial will show how easy it is to extract data using these tools and more! ...

If Cell is This Value or That Value

IF function is frequently used in Excel worksheet to return you expect “true value” or “false value” based on the result of logical test. If you want to see if a cell is A or B, and if one of ...

If Value is Greater Than A Certain Value
If Value is Greater Than A Certain Value 1

IF function is frequently used in Excel worksheet to return you expect “true value” or “false value” based on the logical test result. If you want to see if a value in one cell is greater than a specific value, ...

If Cell is Not Blank
If Cell is Not Blank 6

IF function is frequently used in Excel worksheet to return you expect “true value” or “false value” based on the result of created logical test. If you want to see if a cell is blank or not, and leave some ...

VBA Macro For VLOOKUP From Another Sheet
vba macro for vlookup from another sheet1

In the previous post, you should know that how to fix or remove the #N/A error when using VLOOKUP formula to lookup value from another sheet. And this post will show you how to use VBA code to vlookup data ...

Sidebar