MATCH & INDEX

Topic 08

MATCH & INDEX

Two functions that work as a pair. MATCH tells you where something is — it returns a position number. INDEX tells you what is at a position — it returns a value. Combined, they solve a problem VLOOKUP and XLOOKUP handle poorly: a two-dimensional lookup — finding a value at the intersection of a row and a column.

Classic lookup group 2D lookup — row × column Training file: Match-index.xlsx

Two Functions — One Job Each

They do opposite things. MATCH converts a value to a position. INDEX converts a position to a value.

MATCH
Value → Position
You give it a value and a range. It tells you which position (row or column number) that value occupies.
"May"
5 (5th row)
"Disk Drives"
1 (1st column)
INDEX
Position → Value
You give it a range and a position (row number, column number). It returns whatever value sits at that intersection.
Row 5, Col 1
6,204
📌
Why use both together?
MATCH alone gives you a number — not very useful on its own. INDEX alone needs numbers you'd have to type manually. Combine them: let MATCH calculate the position, feed it directly into INDEX, and the result updates automatically whenever the selection changes.

MATCH — and its Default Problem

MATCH has the same default issue as VLOOKUP — approximate match unless you explicitly add 0. XMATCH is the modern version that fixes this.

= MATCH(lookup_value, lookup_array, [match_type])
lookup_value The value to find — e.g. the selected month A3 or product A4.
lookup_array The row or column to search in. For months: the months column. For products: the products header row.
[match_type] Default is 1 (approximate, ascending) — same trap as VLOOKUP. Always write 0 for exact match unless you specifically need approximate. If omitted, results can be silently wrong.

MATCH vs XMATCH

⚠️ MATCH — requires the zero
Find position of "May" in the months column
= MATCH(A3, months_col, 0)
Forget the 0 → wrong result, no error warning.
✓ XMATCH — exact match by default
Same result, safer by default
= XMATCH(A3, months_col)
No 3rd argument needed. Exact match is the default.
💡
MATCH and XMATCH return the same thing
Both return a position number — an integer. That number is what gets passed to INDEX. You can use either one inside the INDEX formula; XMATCH is just safer as the default is exact match.

INDEX — Return a Value by Position

INDEX takes a data range and returns the value at a specified row and column position within that range.

= INDEX(array, row_num, [col_num])
array The data grid — the range of numbers to return from. Does not need to include the headers or month labels.
row_num Which row inside the array to return from. Row 1 = first data row, row 5 = fifth data row. This is where MATCH feeds in.
[col_num] Which column inside the array. Optional for a single-column array, required for a multi-column grid. This is where the second MATCH feeds in.

The 2D Lookup — Row × Column

The file has a grid of monthly sales by product. A3 holds a selected month Data Validation — coming later and A4 holds a selected product. The task is to return the sales value at their intersection.

Month Disk Drives CD Drives DVD Drives Flash Drives Combined
January 5,7603,7405,0294,71819,247
February 6,7392,7394,9932,61517,086
March 6,3383,3584,2655,31219,273
April 5,0134,8664,5651,10815,552
May ← A36,204 ✓2,0484,7661,99415,012
June 6,5222,8425,3793,83018,573
July 6,4562,7144,1713,23216,573
August 6,8362,0815,0771,60715,601
September5,9674,5744,7541,56316,858
October 6,5764,0084,8302,59018,004
November 6,0424,2354,2243,96018,461
December 5,5663,7515,1033,01317,433

A3 = "May" · A4 = "Disk Drives" → result = 6,204 (highlighted cell)


Building the Formula — Step by Step

Build each piece independently first, then combine them.

1
MATCH — find the row
Where is the selected month in the months column?
Search for the value in A3 ("May") in the months column. Returns the position number — 5, because May is the 5th month.
= MATCH(A3, months_col, 0) → returns 5
→ 5
2
MATCH — find the column
Where is the selected product in the header row?
Search for the value in A4 ("Disk Drives") in the products header row. Returns 1, because Disk Drives is the 1st product column.
= MATCH(A4, products_row, 0) → returns 1
→ 1
3
INDEX — return the value
What is at row 5, column 1 of the data grid?
Use INDEX with the data range and the two position numbers. Replace the hardcoded 5 and 1 with the MATCH formulas from Steps 1 and 2.
= INDEX(data_range, 5, 1) → returns 6,204 (hardcoded — for illustration)
= INDEX(data_range, MATCH(A3, months_col, 0), MATCH(A4, products_row, 0)) → 6,204 ✓
→ 6,204
4
Modern version — with XMATCH
Same result — exact match by default, no 0 needed
Replace MATCH with XMATCH. The formula is identical in structure but the 3rd argument is no longer needed — exact match is the default.
= INDEX(data_range, XMATCH(A3, months_col), XMATCH(A4, products_row)) → 6,204 ✓
⚠️
months_col, products_row, data_range — verify in your file
Replace these placeholder names with the actual cell references from Match-index.xlsx. The months column is the range containing January–December. The products row is the range containing the product header names. The data range is the numbers grid — without the month labels and without the header row.

Training Exercise

Open Match-index.xlsx. Cell A3 has a Data Validation dropdown for the month, A4 for the product. Write the INDEX + MATCH formula in the yellow result cell. Then test by changing the selections in A3 and A4 — the result should update to match the correct intersection every time.

Download Match-index.xlsx
Verification
A3 = May, A4 = Disk Drives → 6,204
A3 = February, A4 = Flash Drives → 2,615
A3 = October, A4 = Combined → 18,004
📌
Why not just use XLOOKUP for this?
XLOOKUP can handle 2D lookups using a nested XLOOKUP, but the syntax becomes complex. INDEX + MATCH is the established pattern for grid lookups — it's cleaner, widely understood, and works in all Excel versions. Both approaches are valid; knowing both makes you versatile.

Practice

citysales.xlsx — 3 Questions

Open the file. Row 3 has city names as column headers. Column A has item codes as row labels. Use INDEX + MATCH + MATCH to find the sales for each item–city combination, then type your answer to check.

Download citysales.xlsx
Q1 What were the sales for item 96B6407V in Alexandria?
Your answer:
Q2 What were the sales for item 21Q7341C in Cairo?
Your answer:
Q3 What were the sales for item 43C5717Z in Dubai?
Your answer: