VLOOKUP Formula to Compare Two Columns in Different Excel Sheets

We have data from two teams that have some common members in two different worksheets named TeamA and TeamB. We’ll find the common names and the different names of the two teams.

Sample dataset to use VLOOKUP Formula to Compare Two Columns in Different Excel Sheets


Method 1 – Compare Two Columns in Different Excel Sheets and Return Common or Matched Values

  • We have created a new worksheet with data of Team B.
  • Create a new column E to find the common names.
  • Insert the following formula into cell E5:
=VLOOKUP(B5,TeamA!B5:B20,1,FALSE)

Inserting VLOOKU formula to Compare Two Columns in Different Worksheets and Return Common / Matched Values

Draggig Fill handle

  • You will get the common names inserted in the column Team A. For the mismatched rows, you’ll get an #N/A Error.

Showing N/A error while Comparing Two Columns in Different Worksheets and Return Common / Matched Values


Using IFERROR with VLOOKUP Function to Treat the #N/A Error

To avoid the showing of ‘#N/A Error” in the column, use the following formula instead:

=IFERROR(VLOOKUP(B5,TeamA!B5:B20,1,FALSE),"Not Found")

Formula Breakdown:

The syntax of IFERROR function: =IFERROR(value, value_if_error)

  • As the value of IFERROR function, we have input our VLOOKUP.  So, if there is no error, the output of the VLOOKUP formula will be the output of the IFERROR function.
  • As the value_if_error argument, we have passed this value, “Not Found”. If the IFERROR function finds an error in the cell, it will output this text, “Not Found”.

Using IFERROR with VLOOKUP Formula to Compare Two Columns in Different Excel Sheets

  • Here’s the updated result.

Substituting N/A error with Not founf using IFERROR function


Using IF and ISNA with VLOOKUP Function to Handle the #N/A Error:

=IF(ISNA(VLOOKUP(B5,TeamA!B5:D20,1,FALSE)),"Not Matched", "Matched")

Using IF and ISNA with VLOOKUP Formula to Compare Two Columns in Different Excel Sheets

Formula Breakdown:

  • ISNA returns a TRUE value if its argument is a N/A error, which is then used for the IF function.
  • Here’s the result of the new formula.

VLOOKUP Formula to Compare Two Columns in Different Excel Sheets

  • Go back to the formula that outputs the names as results.
  • Click on any cell of the dataset.
  • Go to the Home tab on the top ribbon.
  • Click on the Sort & Filter option and select Filter.

Applying Filter Feature

  • You will filter drop-down arrows in each header of the dataset.
  • Click on the Filter arrow in the Column Team A.
  • Unmark the checkbox “Not Found” and press OK.

uncheck Not Found option to apply filter

  • You will see only the common or matched names of the two teams. Mismatched names are hidden by the Filter Feature.

Showing only the matched values of two different lists from different worksheets


Method 2 – Compare Two Columns in Different Worksheets and Find Missing Values

Case 2.1 – Using the Filter Feature

  • Use the VLOOKUP formula with the IFERROR function from Method 1.
  • Go to the Filter option by clicking the Filter arrow in the column header of Team A.
  • Unmark all the checkboxes except that saying “Not Found”.
  • Press OK.

Mark only 'Not Found" in Filter Feature to show the mismatched values

  • You will see that only the mismatched names of Team B compared to Team A are shown in the dataset.

showing only the mismatched values using filter feature and VLOOKUP function


Case 2.2 – Using FILTER with VLOOKUP Function

  • Insert the following formula into cell F5.
=FILTER(B5:B20, ISNA(VLOOKUP(B5:B20, TeamA!B5:B20, 1, FALSE)))

Formula Breakdown:

  • The VLOOKUP function will find the common names between the range B5:B20 of the active worksheet and range B5:B20 of the worksheet TeamA and assign #N/A for the mismatched.
  • The ISNA function will take only the cells that are assigned #N/A by VLOOKUP functions which means they are mismatched.
  • The Filter function will insert only the cells from range B5:B20 which are mismatched and assigned #N/A.

Using FILTER with VLOOKUP Function


Method 3 – Compare Two Lists in Different Worksheets and Return a Value from a Third Column+

  • Change the column index number in the VLOOKUP. We want to get the age of the name “James” and the age values are contained in the 4th column of the selected VLOOKUP range in the TeamB worksheet.
  • Insert the following formula into the cell E5:
=FILTER(B5:B20, ISNA(VLOOKUP(B5:B20, TeamA!B5:B20, 1, FALSE)))

applying VLOOKUP formula

  • We get the ages for the names that match the list in TeamA. For the mismatched names, we get an #N/A error.

Compare Two Lists in Different Worksheets and Return a Value from a Third Column

Read More: How to Compare Three Columns and Return a Value in Excel


VLOOKUP for Multiple Columns in Different Sheets in Excel with One Return Only

We’re considering a situation with Item ID and Product Name of some products in a worksheet named W1 and Product Name and Price in another worksheet named W2. We’ll find the price of the product based on its ID.

  • Make a new sheet and list item IDs you want to find in column B starting with B5.
  • Insert this formula into cell C5 of that sheet:
=VLOOKUP(VLOOKUP(B6,'W1'!B6:C19,2,FALSE),'W2'!B6:C19,2,FALSE)
  • Lookup_value is VLOOKUP(B6,’W1′!B6:C19,2,FALSE). This second “VLOOKUP” will pull the Item ID from the “W1
  • table_array: is ‘W2′!B6:C19.
  • Col_index_num is 2
  • [range_lookup]: we want the exact match (FALSE)

Applying VLOOKUP formula for Multiple Columns in Different Worksheets in Excel with Only One Return

  • Drag the Fill Handle icon to apply the formula to other cells of the column.

VLOOKUP for Multiple Columns in Different Worksheets in Excel with Only One Return


Download the Practice Workbook


<< Go Back to Columns | Compare | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Kawser Ahmed
Kawser Ahmed

Kawser Ahmed is a Microsoft Excel Expert, Udemy Course Instructor, Data Analyst, Finance professional, and Chief Editor of ExcelDemy. He is the founder and CEO of SOFTEKO (a software and content marketing company). He has a B.Sc in Electrical and Electronics Engineering. As a Udemy instructor, he offers 8 acclaimed Excel courses, one selected for Udemy Business. A devoted MS Excel enthusiast, Kawser has contributed over 200 articles and reviewed thousands more. His expertise extends to Data Analysis,... Read Full Bio

6 Comments
  1. Hii

    In sheet 1, column C (Owner Names) and Column D (Tenant names) are provided along with “Comments” in Column E for a city. And in sheet 2, owner names are provided in column F, and tenant names are in Column H, but comments are not provided.
    Now I want, if in sheet1, any of the rows, the Owner name and tenant name exactly match with the owner’s name and tenant name in Sheet2 . then the comments should be copied from sheet 1 to sheet 2 in column O. In other words, if Column C & Column D (Sheet1) = Column F & Column H (Sheet 2), then from sheet 1 column E (Comments) should be pasted in Column O in the sheet 2.

    Hope I have described my problem clearly, please help me to generate the formula for this.

    • Reply Avatar photo
      Osman Goni Ridwan Aug 30, 2022 at 3:32 PM

      Hello AVINASH! I have made a dataset as per your description and solved your problem. You can paste the following formula into the column O and the 3rd row to get the comment from sheet 1 when the criteria are met:

      =IF(AND(F4=Sheet1!C4,Sheet2!H4=Sheet1!D4),Sheet1!E4,"")

      Try this for your dataset and let us know the outcome. Thank You!

  2. I have selected a product in Column E of row 4 Sheet1 and I want the selected product to be searched in Column B of Product List and get the result in Column M of Sheet2

    • Reply Avatar photo
      Nazmul Hossain Shovon Oct 24, 2022 at 3:39 PM

      Hi Brijesh,
      I have created a simplified solution below. Please follow them:
      1. I am assuming that you have a Sheet1 like below:
      starting dataset
      2. Now, go to the Sheet2 and insert the following formula in cell C5:
      =IFERROR(VLOOKUP(Sheet1!$B$5,B5:B12,1,FALSE),"Not Found")
      formula
      3. Now, simply copy this formula down using Fill Handle and this should tell you whether the product in cell B5 inside Sheet1 exists in the Product List column or not.
      final result

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo