How to Compare Two Columns in Excel (using VLOOKUP & IF) (2024)

When you’re working with data in Excel, sooner or later you will have to compare data. This could be comparing two columns or even data in different sheets/workbooks.

In this Excel tutorial, I will show you different methods to compare two columns in Excel and look for matches or differences.

There are multiple ways to do this in Excel and in this tutorial I will show you some of these (such as comparing using VLOOKUP formula or IF formula or Conditional formatting).

So let’s get started!

Table of Contents

Compare Two Columns (Side by Side)

This is the most basic type of comparison where you need to compare a cell in one column with the cell in the same row in another column.

Suppose you have a dataset as shown below and you simply want to check whether the value in column A in a specific cell is the same (or different) when compared with the value in the adjacent cell.

How to Compare Two Columns in Excel (using VLOOKUP & IF) (1)

Of course, you can do this when you have a small dataset when you have a large one, you can use a simple comparison formula to get this done. And remember, there is always a chance of human error when you do this manually.

So let me show you a couple of easy ways to do this.

Compare Side by Side Using the Equal to Sign Operator

Suppose you have the below dataset and you want to know what rows have the matching data and what rows have different data.

How to Compare Two Columns in Excel (using VLOOKUP & IF) (2)

Below is a simple formula to compare two columns (side by side):

=A2=B2

How to Compare Two Columns in Excel (using VLOOKUP & IF) (3)

The above formula will give you a TRUE if both the values are the same and FALSE in case they are not.

Now, if you need to know all the values that match, simply apply a filter and only show all the TRUE values. And if you want to know all the values that are different, filter all the values that are FALSE (as shown below):

How to Compare Two Columns in Excel (using VLOOKUP & IF) (4)

When using this method to do column comparison in Excel, it’s always best to check that your data does not have any leading or trailing spaces. If these are present, despite having the same value, Excel will show them as different. Here is a great guide on how to remove leading and trailing spaces in Excel.

Compare Side by Side Using the IF Function

Another method that you can use to compare two columns can be by using the IF function.

This is similar to the method above where we used the equal to (=) operator, with one added advantage. When using the IF function, you can choose the value you want to get when there are matches or differences.

For example, if there is a match, you can get the text “Match” or can get a value such as 1.

Similarly, when there is a mismatch, you can program the formula to give you the text “Mismatch” or give you a 0 or blank cell.

Below is the IF formula that returns ‘Match’ when the two cells have the cell value and ‘Not a Match’ when the value is different.

=IF(A2=B2,"Match","Not a Match")

How to Compare Two Columns in Excel (using VLOOKUP & IF) (5)

The above formula uses the same condition to check whether the two cells (in the same row) have matching data or not (A2=B2).

But since we are using the IF function, we can ask it to return a specific text in case the condition is True or False.

Once you have the formula results in a separate column, you can quickly filter the data and get rows that have the matching data or rows with mismatched data.

Also read: Does Not Equal Operator in Excel (Examples)

Highlight Rows with Matching Data (or Different Data)

Another great way to quickly check the rows that have matching data (or have different data), is to highlight these rows using conditional formatting.

You can do both – highlight rows that have the same value in a row as well as the case when the value is different.

Suppose you have a dataset as shown below and you want to highlight all the rows where the name is the same.

How to Compare Two Columns in Excel (using VLOOKUP & IF) (6)

Below are the steps to use conditional formatting to highlight rows with matching data:

  1. Select the entire dataset (except the headers)
  2. Click the Home tabHow to Compare Two Columns in Excel (using VLOOKUP & IF) (7)
  3. In the Styles group, click on Conditional FormattingHow to Compare Two Columns in Excel (using VLOOKUP & IF) (8)
  4. In the options that show up, click on ‘New Rule’How to Compare Two Columns in Excel (using VLOOKUP & IF) (9)
  5. In the ‘New Formatting Rule’ dialog box, click on the option -”Use a formula to determine which cells to format’How to Compare Two Columns in Excel (using VLOOKUP & IF) (10)
  6. In the ‘Format values where this formula is true’ field, enter the formula: =$A2=$B2How to Compare Two Columns in Excel (using VLOOKUP & IF) (11)
  7. Click on the Format buttonHow to Compare Two Columns in Excel (using VLOOKUP & IF) (12)
  8. Click on the ‘Fill’ tab and select the color in which you want to highlight the rows with the same value in both columnsHow to Compare Two Columns in Excel (using VLOOKUP & IF) (13)
  9. Click OK

The above steps would instantly highlight the rows where the name is the same in both columns A and B (in the same row). And in the case where the name is different, those rows will not be highlighted.

How to Compare Two Columns in Excel (using VLOOKUP & IF) (14)

In case you want to compare two columns and highlight rows where the names are different, use the below formula in the conditional formatting dialog box (in step 6).

=$A2<>$B2

How does this work?

When we use conditional formatting with a formula, it only highlights those cells where the formula is true.

When we use $A2=$B2, it will check each cell (in both columns) and see whether the value in a row in column A is equal to the one in column B or not.

In case it’s an exact match, it will highlight it in the specified color, and in case it doesn’t match, it will not.

The best part about conditional formatting is that it doesn’t require you to use a formula in a separate column. Also, when you apply the rule on a dataset, it remains dynamic. This means that if you change any name in the dataset, conditional formatting will accordingly adjust.

Compare Two Columns Using VLOOKUP (Find Matching/Different Data)

In the above examples, I showed you how to compare two columns (or lists) when we are just comparing side by side cells.

In reality, this is rarely going to be the case.

In most cases, you will have two columns with data and you would have to find out whether a data point in one column exists in the other column or not.

In such cases, you can’t use a simple equal-to sign or even an IF function.

You need something more powerful…

… something that’s right up VLOOKUP’s alley!

Let me show you two examples where we compare two columns in Excel using the VLOOKUP function to find matches and differences.

Compare Two Columns Using VLOOKUP and Find Matches

Suppose we have a dataset as shown below where we have some names in columns A and B.

How to Compare Two Columns in Excel (using VLOOKUP & IF) (15)

If you have to find out what are the names that are in column B that are also in column A, you can use the below VLOOKUP formula:

=IFERROR(VLOOKUP(B2,$A$2:$A$10,1,0),"No Match")

How to Compare Two Columns in Excel (using VLOOKUP & IF) (16)

The above formula compares the two columns (A and B) and gives you the name in case the name is in column B as well A, and it returns “No Match” in case the name is in Column B and not in Column A.

By default, the VLOOKUP function will return a #N/A error in case it doesn’t find an exact match. So to avoid getting the error, I have wrapped the VLOOKUP function in the IFERROR function, so that it gives “No Match” when the name is not available in column A.

You can also do the other way round comparison – to check whether the name is in Column A as well as Column B. The below formula would do that:

=IFERROR(VLOOKUP(A2,$B$2:$B$6,1,0),"No Match")

Compare Two Columns Using VLOOKUP and Find Differences (Missing Data Points)

While in the above example, we checked whether the data in one column was there in another column or not.

You can also use the same concept to compare two columns using the VLOOKUP function and find missing data.

Suppose we have a dataset as shown below where we have some names in columns A and B.

How to Compare Two Columns in Excel (using VLOOKUP & IF) (17)

If you have to find out what are the names that are in column B that not there in column A, you can use the below VLOOKUP formula:

=IF(ISERROR(VLOOKUP(B2,$A$2:$A$10,1,0)),"Not Available","Available")

How to Compare Two Columns in Excel (using VLOOKUP & IF) (18)

The above formula checks the name in column B against all the names in Column A. In case it finds an exact match, it would return that name, and in case it doesn’t find and exact match, it will return the #N/A error.

Since I am interested in finding the missing names that are there is column B and not in column A, I need to know the names that return the #N/A error.

This is why I have wrapped the VLOOKUP function in the IF and ISERROR functions. This whole formula gives the value – “Not Available” when the name is missing in Column A, and “Available” when it’s present.

To know all the names that are missing, you can filter the result column based on the “Not Available” value.

You can also use the below MATCH function to get the same result:

=IF(ISNUMBER(MATCH(B2,$A$2:$A$10,0)),"Available","Not Available")

Common Queries when Comparing Two Columns

Below are some common queries I usually get when people are trying to compare data in two columns in Excel.

Q1. How to compare multiple columns in Excel in the same row for matches? Count the total duplicates also.

Ans. We have given the procedure to compare two columns in excel for the same row above. But if you want to compare multiple columns in excel for the same row then see the example

=IF(AND(A2=B2, A2=C2),"Full Match", "")

Here we have compared data of column A, column B, and column C. After this, I have applied the above formula in column D and get the result.

How to Compare Two Columns in Excel (using VLOOKUP & IF) (19)

Now to count the duplicates, you need to use the Countif function.

=IF(COUNTIF($A2:$E2, $A2)=5, "Full Match", "")

Q2. Which operator do you use for matches and differences?

Ans. Below are the operators to use:

  • To find matches, use the equal to sign (=)
  • To find differences (mismatches), use the not-equal-to sign (<>)

Q3. How to compare two different tables and pull matching data?

Ans. For this, you can use the VLOOKUP function or INDEX & MATCH function. To understand this thing in a better way, we will take an example.

Here, we will take two tables and now want to do pull matching data. In the first table, you have a dataset, and in the second table, take the list of fruits and then pull matching data in another column. For pull matching, use the formula

=INDEX($B$2:$B$6,MATCH($D2,$A$2:$A$6,0))

How to Compare Two Columns in Excel (using VLOOKUP & IF) (20)

Q4. How to remove duplicates in Excel?

Ans. To remove duplicate data you need to first find the duplicate values.

To find the duplicate, you can use various methods like conditional formatting, Vlookup, If Statement, and many more. Excel also has an in-built tool where you can just select the data, and remove the duplicates from a column or even multiple columns

Q5. I can see that there is a matching value in both columns.However, the formulas you have shared above are not considering these as exact matches. Why?

Ans: Excel considers something an exact match when each and every character of one cell is equal to the other. There is a high chance that in your dataset there are leading or trailing spaces.

Although these spaces may still make the values seem equal to a naked eye, for Excel these are different. If you have such a dataset, it’s best to get rid of these spaces (you can use Excel functions such as TRIM for this).

Q7. How do we compare two columns that give the result as TRUE when all the first columns’ integer values are not less than the second column’s integer values? To solve this problem, I do not require conditional formatting, Vlookup function, If Statement, and any other formulas. I need the formula to solve this problem.

Ans. You can use the array formula for solving this problem.

The syntax is {=AND(H6:H12>I6:I12)}. This will give you “True” as a result whenever the value of Column H is greater than the value in Column I else “False” will be the result.

You may also like the following Excel tutorials:

  • Compare Two Columns in Excel (for matches and differences)
  • How to Remove Blank Columns in Excel? (Formula + VBA)
  • How to Hide Columns Based On Cell Value in Excel
  • How to Split One Column into Multiple Columns in Excel
  • How to Select Alternate Columns in Excel (or every Nth Column)
  • How to Paste in a Filtered Column Skipping the Hidden Cells
  • Best Excel Books (that will make you an Excel Pro)
  • How to Flip Data in Excel (Columns, Rows, Tables)?
  • Find the Closest Match in Excel (Nearest Value)
  • How to Compare Two Cells in Excel?
  • VLOOKUP Not Working – 7 Possible Reasons + How to Fix!
How to Compare Two Columns in Excel (using VLOOKUP & IF) (2024)

FAQs

How to Compare Two Columns in Excel (using VLOOKUP & IF)? ›

You can compare two columns using the IF condition in Excel. The formula to compare two columns is =IF(B4=C4,”Yes”,” ”). It returns the result as Yes against the rows that contain matching values, and the remaining rows are left empty.

How do I compare two columns in Excel with if statement? ›

You can compare two columns using the IF condition in Excel. The formula to compare two columns is =IF(B4=C4,”Yes”,” ”). It returns the result as Yes against the rows that contain matching values, and the remaining rows are left empty.

Can we use VLOOKUP and IF function together in Excel? ›

Did you know that you can use Excel IF statements along with VLOOKUPs? For example, if you wanted to enter a value from a table into a cell, based on what was in another cell, you could start with an IF statement and then enter the VLOOKUP in the “value if true” part of the IF statement.

How to compare two columns in Excel for differences? ›

One popular method for comparing two columns in Excel is to follow these steps: select both columns of data → go to the Home tab → click on Find & Select → choose Go To Special → select Row Differences → click OK.

How can the VLOOKUP function be used to compare two lists of data? ›

Type in the first part of the VLOOKUP formula, which is “=VLOOKUP(", followed by the letter-number combination representing the empty cell. Include the cells for both target columns, followed by the number of items in each. Add the value "1" to indicate you're only searching through one other column to compare lists.

What is the difference between Xlookup and VLOOKUP? ›

While VLOOKUP is limited to searching only in the first column in the specified table_array, XLOOKUP can look up values in any column, not just the leftmost one. This means XLOOKUP can easily perform bi-directional lookups without needing any data rearrangement.

How do you write an IF THEN formula in Excel? ›

Use the IF function, one of the logical functions, to return one value if a condition is true and another value if it's false. For example: =IF(A2>B2,"Over Budget","OK") =IF(A2=B2,B4-A4,"")

Can I combine VLOOKUP and Sumif? ›

You can use VLOOKUP and SUMIF (or SUMIFS for multiple criteria) together in Excel for various purposes—for example: VLOOKUP within SUMIF, when you need to sum values based on conditions, but you also have to lookup from another table to get the correct criteria value.

How do I VLOOKUP match two columns? ›

The formula in Excel to compare two columns using VLOOKUP is as follows. VLOOKUP(A2,..,..,..) – takes the value in cell A2. VLOOKUP(A2, $B$2:$B$5,..,..) – compares with all the values in cells from B2 to B5. That's why the cells in the range B2:B5 are locked using absolute reference.

How to add 2 VLOOKUP formulas in Excel? ›

All you have to do is nest the first VLOOKUP formula inside the input of the second VLOOKUP formula. Here, the inner VLOOKUP looks for the book's name and returns the ID. The outer VLOOKUP looks for the book's ID and returns its price from Table 2. That's all folks!

How to do VLOOKUP on multiple columns? ›

Type the formula in the first cell, press Ctrl + Shift + Enter, and then drag it down to a few more cells. Select several adjacent cells in a single column (F1:F11 in the screenshot below), type the formula and press Ctrl + Shift + Enter to complete it.

What is the formula to compare two cells in Excel? ›

Compare Two Cells using Equals Operator

For instance, if you want to compare the values in cells A1 and B1, you would enter the formula =A1=B1 in another cell.

References

Top Articles
Dokumente online unterzeichnen: Einfache und sichere E-Signatur-Lösungen
Free Online Signature Generator (Type or Draw) | Signaturely
What Is a Megapixel: Essential Guide [Megapixels Explained]
Www Craigslist Com Wisconsin Milwaukee
Best Places To Get Free Furniture Near Me | Low Income Families
Transfer and Pay with Wells Fargo Online®
How to Book Via Rail Tickets Online?
Pogo Express Recharge
Craigslist Furniture By Owner Dallas
Lojë Shah me kompjuterin në internet. Luaj falas
Mandy Sacs On BLP Combine And The Vince McMahon Netflix Documentary
Mta Bus Time Q85
1v1 lol unblocked Game- Play Unblocked Game Online for Free!
Crystal Lust Wiki
Warped Pocket Dimension
Metalico Sharon Pa
Cuộc thi “Chung tay vì an toàn giao thông” năm 2024
Sites Like SkiptheGames Alternatives
Pathfinder 2E Throwing Weapons
T33N Leaks 5 17
Long-awaited Ringu sequel Sadako doesn’t click with the 21st century
North Colonie Continuing Education
Usccb 1 John 4
Carefirst.webpay.md
Aspen Portal Amherst Ny
Express Pay Cspire
2022 NFL Predictions
Altametrics Login Little Caesars
5162635626
Seconds Valuable Fun Welcoming Gang Back Andy Griffith's Birthday A Top Wish So A Happy Birthday FZSW A Fabulous Man Kevin Talks About Times From Ten Day Weekend Fun Labor Day Break
321 Flea Market Gastonia Nc
Dom's Westgate Pizza Photos
Erfolgsfaktor Partnernetzwerk: 5 Gründe, die überzeugen | SoftwareOne Blog
Erfahrungen mit Rheumaklinik Bad Aibling, Reha-Klinik, Bayern
Hondros Student Portal
Craigslist Cars And Trucks Delaware
Surprise | Visit Arizona
Best Hair Salon Dublin | Hairdressers Dublin | Boombae
Craigslist Lake Charles
New York Sports Club Carmel Hamlet Photos
Commuter Rail Gloucester
Scarabaeidae), with a key to related species – Revista Mexicana de Biodiversidad
Alfyn Concoct
MAXSUN Terminator Z790M D5 ICE Motherboard Review
Avalon Hope Joi
Used Cars for Sale in Phoenix, AZ (with Photos)
Pge Set Up Service
Webworx Call Management
Theresa Alone Gofundme
Assistant Store Manager Dollar General Salary
Giorgia Meloni, die Postfaschistin und ihr "linker" Lebensgefährte
How to Screenshot on Cash App: A Complete Guide
Latest Posts
Article information

Author: Aron Pacocha

Last Updated:

Views: 6438

Rating: 4.8 / 5 (68 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Aron Pacocha

Birthday: 1999-08-12

Address: 3808 Moen Corner, Gorczanyport, FL 67364-2074

Phone: +393457723392

Job: Retail Consultant

Hobby: Jewelry making, Cooking, Gaming, Reading, Juggling, Cabaret, Origami

Introduction: My name is Aron Pacocha, I am a happy, tasty, innocent, proud, talented, courageous, magnificent person who loves writing and wants to share my knowledge and understanding with you.