When grappling with extensive data scattered across various worksheets within your Excel workbook, the VLOOKUP function emerges as a valuable ally. Not only is VLOOKUP among the most useful functions in Excel, but it also stands out as one of the more intricate ones. This function proves instrumental in consolidating data from multiple sheets in a coherent manner. This article delves into the nuances of employing the VLOOKUP function from another sheet in Excel, covering two distinct cases.
Introduction to the VLOOKUP Function in Excel
In straightforward terms, the VLOOKUP function takes user-input, searches for it within the Excel worksheet, and retrieves a corresponding value associated with the given input. This functionality spans across all versions of Excel, starting from Excel 2007.
Key Points
The VLOOKUP function processes the input value, scans the worksheets for a match, and furnishes the corresponding value.
Syntax
=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
Argument
Result
Yields an exact or approximate value corresponding to the user's provided input.
Utilizing VLOOKUP Across Different Sheets: Two Scenarios
Applying the VLOOKUP function to retrieve values can involve two distinct scenarios—either from a single alternative worksheet or multiple worksheets. Below, we'll illustrate these two cases.
Case 1: VLOOKUP from Another Single Sheet
Here, we'll explore how to employ the VLOOKUP function when extracting data from a separate sheet within the same workbook. Consider a dataset featuring "ID" numbers, Sales Reps' "Names," "Regions," and "Salaries," as shown in the provided image. In this dataset, the ID numbers are assigned arbitrarily, and our objective is to place the ID number in a different worksheet and extract the associated information.
🔗 Steps:
1. Begin by creating a new worksheet where you intend to retrieve information matching the ID number using the VLOOKUP function.
2. Apply the VLOOKUP function in the Name Column:
=VLOOKUP(B5, 'Employee Data'!B$5:E$15, 2, FALSE)
- Lookup_value is B$5- table_array is 'Employee Data'!B$5:E$15 (Select the array from the employee data worksheet)- Col_index_num is 2- [range_lookup] is set to FALSE for an exact match.
3. Press "ENTER" to obtain the value from another worksheet.
4. Select the cell containing the function, and using the Fill Handle, drag downward to Autofill the formula into the subsequent cells.
5. As a result, you will get the same result for the rest of the ID numbers.
*Note: The lookup range, 'B$4:E$14,' indicates a locked column, ensuring that cell references won't change when copying or dragging the formula. Using absolute cell reference ($B$4:$E$14) would freeze both the row and column.*
6. Hold the Fill Handle, select the column Name, and drag the mouse to the right-end corner to populate the remaining results.
By following these steps, all subsequent cells will auto-fill with the VLOOKUP function, providing the desired results for the remaining ID numbers.
2. VLOOKUP Across Multiple Sheets
When the need arises to search for values across two or more sheets, the earlier method may not be the most convenient. The optimal solution involves employing the VLOOKUP function with nested IFERROR or Nested INDIRECT functions to systematically search between worksheets. Let's delve into this technique.
2.1. Utilizing the IFERROR Function
Consider a scenario where we have three worksheets containing employee data from the "India," "Nepal," and "Japan" regions.
Our goal is to locate their salary in a new worksheet using their ID number as input, employing VLOOKUP nested within the IFERROR function. The formula format is as follows:
=IFERROR(VLOOKUP(…), IFERROR(VLOOKUP(…), …, "Not found"))
If no value is found, the formula gracefully returns "NOT FOUND".
🔗 Steps:
1. Begin by creating a new worksheet featuring the ID number and Salary column. Input the desired ID number in the ID column.
2. Apply the following formula containing VLOOKUP with the IFERROR function:
=IFERROR(VLOOKUP(B5, India!$B$5:$E$10, 4, FALSE), IFERROR(VLOOKUP(B5, Nepal!$B$5:$E$10, 4, FALSE), IFERROR(VLOOKUP(B5, Japan!$B$5:$E$10, 4, FALSE), "NOT FOUND")))
- Lookup_Value is B5- Sheet_range includes India!$B$5:$E$10, Nepal!$B$5:$E$10, Japan!$B$5:$E$10- Col_index_num is 4- Range_lookup is set to False for an Exact Match
3. Press ENTER to retrieve the value.
4. Copy the formula for the remaining cells.
Upon inspection, in the case of ID number "1102316," the value is "NOT FOUND" since this ID number does not exist in the specified worksheets. Thus, the VLOOKUP from another sheet in Excel is successfully executed using this approach.
Read More: VLOOKUP Example Between Two Sheets in Excel
2.2. Utilizing the INDIRECT Function
An alternative method for VLOOKUP across multiple sheets in Excel involves a combination of the "VLOOKUP" and "INDIRECT" functions, alongside INDEX, MATCH, and COUNTIF functions. Introducing an additional worksheet named "Africa" alongside the three lookup sheets mentioned in Method 2.1, let's explore this approach.
Now, let's consider four distinct worksheets containing employee information and apply the following formula on a new compilation worksheet:
=VLOOKUP(lookup_value, INDIRECT("'" & INDEX(Lookup_sheets, MATCH(1, --(COUNTIF(INDIRECT("'" & Lookup_sheets & "'!lookup_range"), lookup_value)>0), 0)) & "'!table_array"), col_index_num, FALSE)
🔗 Steps:
1. Name the worksheets as "India," "Nepal," "Japan," and "Africa." Write down all the lookup sheet names in any cell of your workbook and name that range.
2. Apply the following formula:
=VLOOKUP($B5, INDIRECT("'" & INDEX(Lookup_Sheets, MATCH(1, --(COUNTIF(INDIRECT("'" & Lookup_Sheets & "'!$B$5:$B$10"), $B5) > 0), 0)) & "'!$B$5:$E$10"), 4, FALSE)
- Lookup_value is $B5.- Lookup_sheets is the named range containing the names of the sheets.- Lookup_range is the column range to look up for ($B$5:$B$10).- Table_array is the data range ($B$5:$E$10).- Col_index_num is 4.- "FALSE" is for the exact match.
3. This is an array formula, so press SHIFT+CTRL+ENTER simultaneously to apply.
💡 Formula Explanation:
The segment `INDIRECT("'" & INDEX(Lookup_Sheets, MATCH(1, --(COUNTIF(INDIRECT("'" & Lookup_Sheets & "'!$B$5:$B$10"), $B5) > 0), 0)) & "'!$B$5:$E$10")` serves as the lookup array for the VLOOKUP function. Let's break it down.
- `Lookup_sheets` is a named range with values: India, Nepal, Japan, Africa.
- `INDIRECT("'" & Lookup_Sheets & "'!$B$5:$B$10")` returns an array: {1102304; 1102310; 1102314; 1102320}.
- `COUNTIF(INDIRECT("'" & Lookup_Sheets & "'!$B$5:$B$10"), $B5)` results in an array: {1; 0; 0; 0}.
- `MATCH(1, --(COUNTIF(INDIRECT("'" & Lookup_Sheets & "'!$B$5:$B$10"), $B5) > 0), 0)` equals 1.
- `INDEX(Lookup_Sheets, MATCH(1, --(COUNTIF(INDIRECT("'" & Lookup_Sheets & "'!$B$5:$B$10"), $B5) > 0), 0))` returns "India."
Now, the formula becomes `VLOOKUP($B5, INDIRECT("'" & "India" & "'!$B$5:$E$10"), 4, FALSE)`.
`INDIRECT("'" & "India" & "'!$B$5:$E$10")` fetches the array $B$5:$E$10 from the India sheet, resulting in: {1102304,"Ronand","India",44000; 1102302,"Duke","India",56000; ...}.
The final output is $12000, corresponding to the given ID number. Repeat this formula for the remaining IDs. Non-existing IDs will yield "#N/A."
💡 Things to Remember:
- The VLOOKUP function searches for lookup values from the leftmost top column to the right.
- A column index number less than 1 will result in an error.
- Use absolute cell references ($) for the "Table_Array".
- Press SHIFT+CTRL+ENTER for array formulas.
Download the Practice Workbook
Feel free to download the accompanying practice sheet to reinforce your understanding as you go through this article.
Conclusion
This article has covered the process of searching for data in one or multiple worksheets and organizing them systematically using the VLOOKUP function from another sheet. While this function may pose a challenge for new users, we've aimed to simplify the explanation as much as possible. We hope this article proves useful for you. If you encounter any confusion, please share your thoughts, and we'll be happy to assist.