Yes, you can join tables in Excel using INDEX and MATCH — it’s a flexible alternative to VLOOKUP that lets you look up values from one table and bring them into another, even when the columns are not in the same order. You enter a lookup value, tell the formula which column to search, and which column to return from, and it gives you the matching value. This article explains how the formula works, when to use it, common mistakes, and how it compares to other lookup methods.
How INDEX and MATCH Work Together
INDEX and MATCH are two separate Excel functions that combine to perform a lookup. MATCH finds the position of a value in a row or column. INDEX returns the value at a given position in a range. When you nest MATCH inside INDEX, the MATCH result becomes the row (or column) number for INDEX.
The basic syntax is:
=INDEX(return_range, MATCH(lookup_value, lookup_range, 0))
- return_range – the column (or row) that contains the value you want to pull.
- lookup_value – the value you are searching for, usually a cell reference.
- lookup_range – the column (or row) where you search for that value.
- 0 – means exact match. Use 0 for most lookups.
For example, if you have a product table with product IDs in column A and prices in column B, and you want to get the price for a product ID in cell E2, the formula would be:
=INDEX(B:B, MATCH(E2, A:A, 0))
This finds the row where E2 appears in column A, then returns the value from column B on that same row.
Why Use INDEX-MATCH Instead of VLOOKUP?
VLOOKUP is the older, more familiar function, but it has limitations that INDEX-MATCH solves:
- Column order: VLOOKUP requires the lookup column to be the first column in the table. INDEX-MATCH can search any column and return from any column.
- Inserting columns: If you add a column to the table, VLOOKUP’s column index number may become wrong. INDEX-MATCH references the actual return range, so it adjusts automatically.
- Performance: On very large datasets, INDEX-MATCH is often faster because it only looks at the two ranges, not the whole table.
- Left lookups: VLOOKUP can only return values to the right of the lookup column. INDEX-MATCH can return values from the left or right.
That said, VLOOKUP is simpler to write and understand for basic lookups. If your table is small and the lookup column is first, VLOOKUP is fine. But if you need flexibility, INDEX-MATCH is the better tool.
Joining Two Tables: Step-by-Step
Joining tables with INDEX-MATCH means you have two tables that share a common column (like an ID or name), and you want to bring data from one table into the other. Here’s how to do it:
- Identify the common column in both tables. For example, Table 1 has customer IDs and names; Table 2 has customer IDs and purchase amounts.
- In Table 1, create a new column for the data you want to pull (e.g., “Purchase Amount�).
- In the first cell of that new column, enter the formula:
=INDEX(Table2_amount_column, MATCH(Table1_customerID_cell, Table2_customerID_column, 0)). - Press Enter, then copy the formula down for all rows.
For example, if Table 1 is in A1:C10 (with customer IDs in column A), and Table 2 is in E1:F10 (IDs in column E, amounts in column F), the formula in C2 would be:
=INDEX(F:F, MATCH(A2, E:E, 0))
This pulls the amount from Table 2 for the matching ID.
Handling Missing Matches and Errors
When a lookup value doesn’t exist in the lookup range, MATCH returns #N/A. This is actually useful because it tells you there is no match. To make the output cleaner, you can wrap the formula in IFERROR:
=IFERROR(INDEX(F:F, MATCH(A2, E:E, 0)), "Not Found")
This displays “Not Found� instead of an error. You can also use “� to leave the cell blank.
Another common issue is duplicate values in the lookup column. MATCH will return the first occurrence, which may not be what you want if duplicates exist. If your lookup column has duplicates, consider using a unique identifier or a more advanced formula like INDEX-MATCH with multiple criteria.
Multiple Criteria: Joining on More Than One Column
Sometimes you need to join tables based on two or more columns (e.g., date and product ID). You can do this with an array formula or by using a helper column. A helper column approach is simpler:
- In both tables, create a helper column that combines the criteria with a separator, like
=A2&"-"&B2. - Then use INDEX-MATCH on the helper columns.
For example, if you need to match on date (column A) and product (column B), create a helper column in both tables: =A2&"-"&B2. Then the formula becomes:
=INDEX(return_range, MATCH(helper_cell, lookup_helper_range, 0))
This works because the combined string is unique.
Alternatively, you can use an array formula like =INDEX(return_range, MATCH(1, (criteria1_range=criteria1)*(criteria2_range=criteria2), 0)), but that requires Ctrl+Shift+Enter in older Excel versions. The helper column is easier to understand and maintain.
Comparing INDEX-MATCH with XLOOKUP and Power Query
XLOOKUP is the modern replacement for both VLOOKUP and INDEX-MATCH. It’s simpler, supports left lookups, and has built-in error handling. For example:
=XLOOKUP(lookup_value, lookup_range, return_range)
If you have Excel 365 or Excel 2021, XLOOKUP is often the best choice. However, INDEX-MATCH still has advantages:
- It works in all Excel versions, including older ones.
- It is more flexible for complex lookups, like matching on multiple criteria without helper columns.
- Some users find it performs better on very large datasets.
Power Query is a different approach: it’s a data transformation tool that can merge tables with a graphical interface. It’s ideal for one-time joins or when you need to refresh data regularly. Power Query is more powerful for complex joins, but it requires learning a new tool and may be overkill for simple lookups.
For most everyday joins, INDEX-MATCH is a solid, reliable choice. For new workbooks, XLOOKUP is simpler. For heavy data work, Power Query is worth learning.
Common Mistakes and How to Avoid Them
- Using approximate match: If you forget the third argument in MATCH, it defaults to 1 (approximate match), which can return wrong results. Always use 0 for exact match.
- Mismatched ranges: The return range and lookup range must be the same size. If you use whole columns (like A:A and B:B), they are the same size, but if you use A1:A10 and B1:B9, the formula will return incorrect results.
- Data type mismatch: If your lookup value is a number but the lookup column contains text (or vice versa), MATCH won’t find it. Ensure both are the same data type.
- Leading/trailing spaces: Extra spaces in text can cause mismatches. Use TRIM() to clean data before lookup.
- Absolute vs. relative references: When copying the formula down, make sure the lookup and return ranges are absolute (with $) so they don’t shift.
Frequently Asked Questions
Can INDEX-MATCH return multiple columns?
Yes, but you need to write a separate formula for each column you want to return. For example, to get both price and stock, you would use two INDEX-MATCH formulas, each with a different return range. Alternatively, you can use an array formula to return multiple values, but that’s more complex.
Is INDEX-MATCH better than VLOOKUP?
It depends. INDEX-MATCH is more flexible (left lookups, column insertions) and often faster on large data. VLOOKUP is easier to learn and write. If your lookup column is first and you don’t expect to insert columns, VLOOKUP is fine. Otherwise, INDEX-MATCH is better.
How do I join tables with INDEX-MATCH when the lookup value appears multiple times?
MATCH returns the first match. If you need all matches, you’ll need a different approach, like using FILTER (in Excel 365) or Power Query. For most joins, you want a unique identifier to avoid duplicates.
Can I use INDEX-MATCH across different sheets or workbooks?
Yes. Just reference the other sheet or workbook in the ranges. For example, =INDEX(Sheet2!B:B, MATCH(A2, Sheet2!A:A, 0)). If the workbook is closed, you may need to keep it open or use full file references.
Why is my INDEX-MATCH returning #N/A?
#N/A means no match was found. Check that the lookup value exists in the lookup range, that data types match, and that there are no extra spaces. Also ensure the ranges are the same size.
What is the difference between INDEX-MATCH and VLOOKUP in terms of speed?
INDEX-MATCH is generally faster on large datasets because it only evaluates the two ranges, not the entire table. VLOOKUP scans the whole table, which can slow down with hundreds of thousands of rows.
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
- Motorola Phone Recovery: How to Recover Data
- Poco X3 GT Dimensity 1100 67W Fast Charging Launched?5.00 min/km
- Flash Converter: What It Is & How to Use It
- Choosing a Pipe Flow Meter for Swirling Flow
- Convert 2D Videos to Oculus Rift VR: How-To
- DRAM Light on Motherboard: Meaning & Fixes5.00 min/km