VLOOKUP merges two tables by pulling matching data from one table into another, using a common key column. You enter the lookup value, the table range, the column number to return, and FALSE for an exact match, and Excel finds the corresponding data. This guide explains how to set it up, common pitfalls, and when to use alternatives like XLOOKUP or INDEX/MATCH.
What Is VLOOKUP and How Does It Work?
VLOOKUP stands for “Vertical Lookup.” It searches for a value in the first column of a table and returns a value from a specified column in the same row. The syntax is:
=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
- lookup_value: the value to search for (e.g., an ID or name).
- table_array: the range of the second table, including the key column and the data you want to pull.
- col_index_num: the column number in the table_array from which to return the value (1 = first column).
- range_lookup: use FALSE for exact match (most common), TRUE for approximate match (e.g., for ranges like tax brackets).
For example, to merge customer names from a lookup table into a sales table using Customer ID, you would write:
=VLOOKUP(A2, $F$2:$G$100, 2, FALSE)
This searches for the value in A2 within column F, and returns the value from column G of that row.
Step-by-Step: How to Merge Two Tables with VLOOKUP
- Identify the common key – the column that appears in both tables (e.g., Product ID, Employee Number).
- Arrange the lookup table so the key column is the first column of the table_array. The data you want to bring back must be to the right of that key.
- In the main table, click the first cell where you want the merged data to appear.
- Enter the VLOOKUP formula referencing the key cell in the current row, the lookup table range (use absolute references like $F$2:$G$100), the column number of the data you want, and FALSE.
- Copy the formula down to fill the column. If you used absolute references, it will adjust correctly.
Make sure the lookup values are formatted the same way in both tables (e.g., both as text or both as numbers). Leading zeros or extra spaces can cause mismatches.
Common Mistakes and How to Avoid Them
- #N/A errors: The lookup value isn’t found. Check for typos, extra spaces, or different data types.
- Wrong column index: The col_index_num is off, returning the wrong column. Count columns in the table_array starting from 1.
- Using TRUE instead of FALSE: Approximate match can return incorrect data if the first column isn’t sorted. Always use FALSE for exact matches.
- Lookup column not first: VLOOKUP only searches the first column of the table_array. If your key is not the first column, rearrange or use INDEX/MATCH.
- Non-printable characters: Data imported from other systems may contain hidden characters. Use TRIM() and CLEAN() to remove them.
When VLOOKUP Isn’t the Best Choice
VLOOKUP has limitations: it can only look to the right, it breaks if columns are inserted, and it’s slower on large datasets. Alternatives include:
- XLOOKUP (Excel 365/2021): can look left or right, returns multiple columns, and has a built-in if-not-found option.
- INDEX/MATCH: more flexible, can look left, and is often faster on large data.
- Power Query: for merging tables in a repeatable, non-formula way.
For most modern users, XLOOKUP is the recommended replacement. It uses the syntax =XLOOKUP(lookup_value, lookup_array, return_array) and doesn’t require a column index.
Merging with VLOOKUP Across Multiple Columns
If you need to bring back several columns, you can write multiple VLOOKUP formulas, one for each column. For example, to get both price and stock:
=VLOOKUP(A2, $F$2:$H$100, 2, FALSE) for price, and =VLOOKUP(A2, $F$2:$H$100, 3, FALSE) for stock.
To avoid repeating the lookup, you can use a helper column that concatenates the key values, or use XLOOKUP with a return array of multiple columns.
Frequently Asked Questions
Why does VLOOKUP return #N/A even though the value exists?
This usually happens due to formatting differences (text vs. number), extra spaces, or invisible characters. Use =TRIM(A2) to remove spaces, and ensure both columns are the same data type. You can also use =VLOOKUP("*"&A2&"*", ...) to match partial text, but that can cause false positives.
Can VLOOKUP merge tables from different sheets?
Yes, just reference the sheet name in the table_array, e.g., =VLOOKUP(A2, Sheet2!$A$1:$B$100, 2, FALSE). If the sheet name has spaces, use single quotes: ='Sheet 2'!$A$1:$B$100.
How do I handle duplicate lookup values in VLOOKUP?
VLOOKUP returns only the first match found. If you need all matches, use INDEX/MATCH with an array formula, or use Power Query to merge and expand duplicates.
What is the difference between VLOOKUP and HLOOKUP?
VLOOKUP searches vertically (down a column) and returns a value from a column to the right. HLOOKUP searches horizontally (across a row) and returns a value from a row below. Use HLOOKUP when your data is laid out in rows instead of columns.
Can I use VLOOKUP to merge tables in Google Sheets?
Yes, VLOOKUP works the same way in Google Sheets. The syntax is identical. You can also use QUERY or INDEX/MATCH for more complex merges.
Why does VLOOKUP return the wrong value when I use TRUE?
TRUE (approximate match) assumes the first column is sorted in ascending order. If it isn’t, you get unpredictable results. Always use FALSE unless you are working with ranges like tax brackets, and ensure the first column is sorted.
Conclusion
VLOOKUP is a powerful tool for merging tables, but it requires careful setup. Always use FALSE for exact matches, ensure the key column is first, and verify your data types. For more flexibility, consider XLOOKUP or INDEX/MATCH. With these tips, you can merge tables confidently and avoid common errors.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Travel Before Starting a Business: How to Decide
- How to Clean Sweat from Over-Ear Headphones Safely
- Crimson Desert Young Monks Mystical Pine Mushroom5.00 min/km
- Lenovo Legion Gaming Phone Renders: What We Know
- Wow Forever Beta Level 30 Cap & Maintenance
- Dig for Eggs Events Schedule: Dates & Info