How to Compare Two Columns or Lists in Excel (4 Suitable Ways)

While doing different tasks in Excel we often come across a situation where the matching and differences of two or multiple columns are required. It’s not a difficult task to compare two columns or lists in Excel but you may get confused as there are so many ways to do it. In this article, we will look for different techniques for matching and differentiating columns in Excel.


How to Compare Two Columns or Lists in Excel: 4 Easy Methods

We have a dataset of two columns. Those columns contain names of items from two showrooms of a super shop. We will compare the data of these two showrooms.

an Excel dataset


1. Compare Two Columns Using Equal Operator

Here, we will compare two columns row-wise using the equal sign. When the items are the same indicate True otherwise False.

📌 Steps:

  • Add a new column on the right side to show the matching status.

  • Put the following formula on Cell D5.
=B5=C5

Compare two columns using equal operator in Excel

  • Now, press Enter and drag the Fill Handle icon.

We can see True appears for match cases otherwise, False.


2. Use Row Differences Command of Go To Special Tool to Compare Two Lists in Excel

In this method, we will use the Row differences technique. It compares those columns row-wise and selects the cells of the second column automatically.

📌 Steps:

  • Select the whole dataset of Range B5:C9.
  • Then, press the F5 button.

  • Then, the Go To dialog box appears. Click on the Special option.

Go To dialog box in Excel

  • Now, select the Row differences option from the Go To Special window.
  • Finally, press OK.

Compare two columns applying row differences technique in Excel

  • We can see two cells of the second column are selected.
  • We change the color of the cells from the Fill Color option.

  • Look at the dataset now.

Change Color of different data cells after comparing two columns in Excel

Cells of the second column with mismatched data are visible now.


3. Use Excel Functions to Compare Two Columns or Lists in Excel

3.1 Using IF Function

Here, we will use the IF function. It will compare the cells of the columns row-wise and check whether they are the same or not.

The IF function checks whether a condition is met, and returns one value if TRUE, and another value if FALSE.

📌 Steps:

  • We put a formula based on the IF function on Cell D5.
=IF(B5=C5,"Match","Mismatch")

Compare two columns using Excel IF function

This formula will check whether the cells are the same or not. If same then, show Match otherwise, Mismatch.

  • Now, drag the Fill Handle icon downwards.

You could use the following formula to compare for not matching values.

=IF(B5<>C5,"Mismatch","Match")

Compare two columns with difference condition

In this case, when the condition is True, it shows Mismatch, otherwise Match.


3.2 Applying EXACT Function

When we have the same data in two columns with case differences, we will use the EXACT function .

The EXACT function checks whether two text strings are exactly the same, and returns TRUE or FALSE. It is case-sensitive.

In Row 6, we have the same data from different cases. Now, apply the EXACT function to see whether it can detect the case difference or not.

📌 Steps:

  • Insert the formula below on Cell D5.
=IF(EXACT(B5,C5),"Match","Mismatch")

Compare two columns using Excel EXACT function

Here, the IF function is used to show the comment based on the decision taken by the EXACT function.

  • Pull the Fill Handle icon.

We get the result. Due to the case difference, Mismatch is showing at Cell D6.


3.3 Using MATCH Function

In this method, we will compare the 1st column with the 2nd column. When the matching of the 1st column is found on the 2nd column result will be TRUE.

Here, we will use the MATCH function with ISERROR and IF functions.

The MATCH function returns the relative position of an item in an array that matches a specified value with a specified order.

📌 Steps:

  • Put the following formula on Cell D5.
=IF(ISERROR(MATCH($B5,$C$5:$C$10,0)),"No match","Match found")

Compare Two Columns Using MATCH Function in Excel

When the statement is true result will be Match found otherwise No match.

  • Press Enter to execute the formula.

We got the result based on the 1st column. We are looking for a match in the 2nd column.

Read More: Excel formula to compare two columns and return a value


4. Compare Two Columns and Highlight Using Conditional Formatting

In this section, we will use conditional formatting to compare two columns and highlight them according to conditions.

4.1 Highlight Equal Values in Two Columns

📌 Steps:

  • Select the dataset first.
  • Go to the Conditional Formatting option from the Home tab.
  • Choose New Rule from the appeared dropdown.

Apply conditional formatting to compare two columns

  • The New Formatting Rule window appears.
  • Select Use a formula to determine which cells to format as the rule type.
  • Put the following formula on the marked box.
=$B5=$C5 

Compare Two Columns Using Excel Conditional Formatting

  • Choose the Fill tab from the Format Cells window.
  • Choose the desired color.
  • Press the OK button.

  • We see the Preview here.
  • Finally, press OK.

Check the preview

  • Look at the dataset.

Highlighting Cells with similar data

Cells with the same data are the highlight.


4.2 Highlight Unique and Duplicate Cells

In this section, we will highlight the unique and duplicate data cells with different colors.

📌 Steps:

  • Enter the New Rule option as shown previously.

  • Select Format only unique or duplicate values rule type.
  • Choose the duplicate option.

Highlight duplicate data cells in Excel

  • Then, set the format color and press OK.

Duplicate cells are highlighted.

  • Again, follow the previous process and choose the unique option.

Highlight unique data cells in Excel

  • Have a final look at the dataset.

Duplicate and unique data care are highlighted differently.


Compare Two Columns in Excel and Count Matches

In this function, we will use the combination of the SUMPRODUCT function, and the COUNTIF function to count the matches. After that, we will calculate the number of total rows using the ROWS function and subtract the matches to get the number of mismatches.

The SUMPRODUCT function returns the sum of products of corresponding ranges or arrays.

📌 Steps:

  • First, we add two rows. One for the match and another for the mismatch.

  • Now, insert the following formula based on the SUMPRODUCT and COUNTIF function on Cell C11.
=SUMPRODUCT(COUNTIF(B5:B9,C5:C9))

Compare Two Columns in Excel and Count Matches

  • Press the Enter button to get the result.

We get the number of matched rows.

  • Now, go to Cell C12 and put the below formula.
=ROWS(B5:C9)-C11

Apply ROWS function to mismatches in Excel

  • Again, press the Enter button to get the number of mismatches.


Compare Two Columns in Excel and Remove Duplicates

In this method, we will show how to remove the duplicates after comparing two columns.

📌 Steps:

  • Select the dataset first.
  • Go to the Conditional Formatting section.
  • Choose Duplicate Values from the Highlight Cells Rules.

  • Choose a color to indicate the duplicates.

Highlight duplicate data cells in Excel

  • We can see the color of cells containing duplicate data has been changed.
  • Now, press Ctrl + Shift+ L to enable the filter option.

Enable filter in Excel

  • Click on the down arrow of the 2nd column.
  • Choose the color of the duplicate cells from the Filter by color section.

  • Only duplicate values are showing now. Select that range.
  • Press the right button of the mouse.
  • Choose the Clear Contents option from the Context Menu.

Compare Two Columns in Excel and Remove Duplicates

  • Duplicate values are removed from the dataset.

  • Again, go to the filter section and check the Select All option.

  • No duplicates are showing now.


Excel Match Two Columns and Extract Output from a Third with VLOOKUP

Here, we have two datasets. 1st one is of Showroom 1 and 2nd is of Showroom 2. We will compare the item columns of each dataset and extract the price from Showroom 1 to Showroom 2 using the VLOOKUP function.

📌 Steps:

  • Apply the formula based on the VLOOKUP function on Cell F5.
  =VLOOKUP($E5,$B$5:$C$10,2,FALSE)

Excel VLOOKUP function to Compare two columns

  • After comparing Item (S1) with Item (S2), we extract the price in the 2nd table.


How to Compare More Than Two Columns in Excel

In the previous sections, we have shown a comparison between two columns. When we have more than two columns, we can use the below methods.

1. Use Excel AND Function

The AND function checks whether all arguments are TRUE, and returns TRUE if all arguments are TRUE.

In this method, after checking all the conditions, the result will be shown based on the comment used in the IF function. Before applying the formula, we add another column named Showroom 3.

📌 Steps:

  • Now, put the formula on Cell E5.
=IF(AND(B5=C5,C5=D5),"Match","Mismatch")  

Compare more that two columns with Excel AND function

  • After that, pull the Fill Handle icon.

Finally, we get the status.


2. Compare with Excel COUNTIF Function

The COUNTIF function counts the number of cells within a range that meet the given condition, and  the COUNTA function counts the number of cells in a range that are not empty.[/wpsm_box]

Here, we will use these functions to compare multiple columns.

📌 Steps:

  • Copy the following formula on Cell E5.
=IF(COUNTIF(B5:D5,B5)=COUNTA(B5:D5),"Match","Mismatch")

Compare more than two columns with Excel COUNTIF function

  • Drag the Fill Handle icon.

Finally, we get the comparison result.


Download Practice Workbook

Download this practice workbook to exercise while you are reading this article.


Conclusion

In this article, we described how to compare two columns or lists in Excel. We compared the columns row-wise and column-wise in both ways. I hope this will satisfy your needs. Please give your suggestions in the comment box if you have any. Goodbye!


<< Go Back to Columns | Compare | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Siam Hasan Khan
Siam Hasan Khan

Hello! Welcome to my Profile. Here I will be posting articles related to Microsoft Excel. I have completed my BSc in Electrical and Electronic Engineering from American International University-Bangladesh. I am a diligent, goal-oriented engineer with an immense thirst for knowledge and an attitude to grow continuously. Continuous improvement and life-long learning are my mottoes.

4 Comments
  1. Very informative and well described.

  2. Excellent! Thanks for this useful information.

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo