Combining INDEX
and MATCH
By combining INDEX
with MATCH
, we can use MATCH
to find the row or column number dynamically, making INDEX
highly flexible for lookups.
- Syntax:
INDEX(range, MATCH(lookup_value, lookup_array, 0), column_number)
Example Scenario
Suppose you have a table of products and their prices in a range A2
. Column A contains product names, and Column B contains prices. You want to look up the price of a specific product.Product | Price |
---|---|
Product A | $20 |
Product B | $30 |
Product C | $25 |
Product D | $35 |
Step-by-Step Formula Breakdown
- Identify the Range: Select the data range (e.g., B2for prices).
- Match the Product Name: Use
MATCH
to find the row number for the product in column A.=MATCH("Product C", A2:A10, 0)
returns the row position of "Product C".
- Combine with
INDEX
: Nest theMATCH
function inside theINDEX
function.=INDEX(B2:B10, MATCH("Product C", A2:A10, 0))
- This formula returns the price of "Product C" from column B.
Why Use INDEX
and MATCH
Over VLOOKUP
?
- Flexibility:
INDEX
andMATCH
allow you to look up values to the left of the lookup column, somethingVLOOKUP
can’t do. - Dynamic Ranges: If you add or remove columns, the
INDEX
andMATCH
formula adapts more easily. - Performance:
INDEX
andMATCH
is generally faster thanVLOOKUP
in large datasets.
Real-World Examples
Example 1: Lookup with Multiple Criteria
Using INDEX
and MATCH
, you can look up values based on multiple criteria by combining MATCH
with an ARRAYFORMULA
.
Example 2: Horizontal Lookups
If your data is organized horizontally, INDEX
and MATCH
can perform horizontal lookups by adjusting the row and column parameters.
Comments
Post a Comment