VLOOKUP is a powerful Excel and Google Sheets function that lets you pull data from one table into another based on a common identifier, such as a product ID, email, or employee number. This guide walks you through merging two tables by matching a key column, so you can combine related information without manual copying. You’ll learn the exact formula, how to set it up, and how to handle common issues.
What You’ll Need
- Two tables in the same spreadsheet (or two separate sheets within the same workbook).
- Each table must have at least one column that contains unique identifiers (e.g., ID, SKU, email). These values must be the same format in both tables (e.g., both as numbers, both as text).
- Basic familiarity with entering formulas in Excel or Google Sheets.
Step-by-Step
- Identify your lookup value. Decide which column in your main table (the one you want to add data to) contains the unique identifier. This is your lookup value. For example, if you have a list of orders with a
Product IDcolumn, that’s your lookup value. - Identify the lookup table. The second table (the one with the data you want to pull) must have the same identifier column. This is your table array. The identifier column must be the first column of this table. For example, if your product details are in columns A (Product ID), B (Product Name), and C (Price), your table array is
A:C. - Determine the column index number. Count columns in your table array starting from the left. The identifier column is column 1. The data you want to pull is the column number you want to return. For example, if you want the Price (column C in the array), that’s column 3.
- Write the VLOOKUP formula. In the first cell of the new column in your main table, enter the formula:
=VLOOKUP(lookup_value, table_array, col_index_num, FALSE)
Replace the arguments with your actual cell references or ranges. For example:=VLOOKUP(A2, Sheet2!$A:$C, 3, FALSE)
This looks up the value in cell A2 (your lookup value) in the first column of Sheet2!$A:$C, and returns the value from the 3rd column of that range. TheFALSEensures an exact match. - Copy the formula down. After entering the formula, drag the fill handle (the small square at the bottom-right corner of the cell) down to apply it to all rows in your main table. Each row will now display the corresponding data from the second table.
- Verify the results. Spot-check a few rows to ensure the data pulled correctly. If you see
#N/Aerrors, it means the lookup value was not found in the table array (see Troubleshooting).
Common Mistakes
- Using approximate match (TRUE) instead of exact match (FALSE). Always use
FALSEunless you have a specific reason for an approximate match (e.g., looking up tax brackets). WithTRUE, Excel may return incorrect data if your lookup values aren’t sorted. - Not making the identifier column the first column of the table array. VLOOKUP can only look to the right. If your identifier is in column B and you want data from column A, you’ll get an error. Rearrange your table or use INDEX/MATCH instead.
- Mixing data types. If one table has IDs as numbers (e.g., 1234) and the other as text (e.g., “1234”), VLOOKUP won’t match them. Convert one to match the other.
- Not locking the table array reference. When copying the formula down, if you don’t use absolute references (with
$), the range will shift, causing errors. Use$A$2:$C$100or a named range. - Copying formulas over existing data. If you paste the formula into a column that already has values, you’ll overwrite them. Always insert a new column first.
Tips
- Use a named range for the table array. This makes the formula easier to read and maintain. For example, name your product table
ProductData, then use=VLOOKUP(A2, ProductData, 3, FALSE). - Use absolute references for the table array. As mentioned, this prevents the range from shifting when you copy the formula.
- Use IFERROR to handle missing values gracefully. Wrap your formula with
=IFERROR(VLOOKUP(...), "Not Found")to display a friendly message instead of#N/A. - Consider using INDEX/MATCH for more flexibility. If your identifier is not in the first column, or you need to look to the left, INDEX/MATCH is a better choice.
- Sort your data if using approximate match. If you must use
TRUE, ensure the first column of the table array is sorted in ascending order.
Troubleshooting
- #N/A error: The lookup value is not found in the first column of the table array. Check for typos, extra spaces, or data type mismatches. Use the TRIM function to remove extra spaces, or convert numbers to text and vice versa.
- #REF! error: The column index number is greater than the number of columns in the table array. Count the columns again.
- #VALUE! error: The column index number is less than 1, or the lookup value is not a valid reference. Check your formula syntax.
- Wrong data returned: If you used
TRUE(approximate match) and your data isn’t sorted, you’ll get incorrect results. Switch toFALSE. - Results not updating: If you change the lookup table and the results don’t update, make sure calculation is set to automatic (Formulas > Calculation Options > Automatic).
Frequently Asked Questions
Can VLOOKUP pull data from another sheet or workbook?
Yes. To reference another sheet, include the sheet name followed by an exclamation mark, e.g., Sheet2!$A:$C. For another workbook, include the workbook name in brackets, e.g., =[Book2.xlsx]Sheet1!$A:$C.
What is the difference between VLOOKUP and INDEX/MATCH?
VLOOKUP can only look to the right of the lookup column. INDEX/MATCH can look in any direction and is more flexible. For most merging tasks, VLOOKUP is simpler, but if your identifier is not in the first column, use INDEX/MATCH.
Why does VLOOKUP return the first match, not the last?
VLOOKUP returns the first match it finds when using FALSE. If you have duplicate values in your lookup column, it will return the first occurrence. To get the last, you’d need a different approach, such as LOOKUP or MAXIFS.
How do I merge more than two tables?
You can perform multiple VLOOKUPs, each pulling a different column from different tables. For example, first merge table A with table B, then merge the result with table C. Alternatively, consider using Power Query (Get & Transform) for more complex merging.
Does VLOOKUP work in Google Sheets?
Yes, VLOOKUP works the same way in Google Sheets. The syntax is identical.
Can I use VLOOKUP to merge tables with different row orders?
Yes, VLOOKUP matches by value, not by row position. The order of rows in your tables doesn’t matter.
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
- Unix Time Converter Milliseconds: How It Works28500000:00:00
- Convert hr:min to min: Quick Guide150 min
- Sales Growth Rate: Formula & How to Calculate20.00 %
- Calculate Days From Now: Date Difference Tool
- 1 mm to cm Calculator: Quick Conversion2.50 cm
- Multiple Services Operator Meaning & How to Use It12.56 m3