Sub topic 12
INDEX with MATCH as a Lookup
This chapter assumes you can enter formulas, use absolute and relative references ($A5, C$3), and have met MATCH and INDEX separately. Here you combine them into a lookup that works in every Excel version and is common in models that other people will open.
How the two functions split the work
A lookup answers two questions: where is the key, and what sits at that position in another column? INDEX with MATCH assigns one question to each function.
- MATCH finds the position of the key inside a one-column or one-row range. It returns a number such as 4, not a value.
- INDEX takes a range and a position, and returns the value stored there.
The key to making this work is that both ranges must cover the same rows in the same order. If the lookup range is B3:B12, the return range must be C3:C12, not C4:C13 and not C3:C20.
=INDEX(Assumptions!$C$3:$C$12, MATCH($A5, Assumptions!$B$3:$B$12, 0))Suppose $A5 holds Tax rate, and that text is the fourth entry in B3:B12. MATCH returns 4. INDEX then returns the fourth cell of C3:C12, which is C6.
=MATCH($A5, Assumptions!$B$3:$B$12, 0)You can test the MATCH half on its own in a spare cell. When a lookup fails, checking the position first usually shows whether the problem is the key or the return range.
The third argument of MATCH
MATCH takes a lookup value, a lookup range, and a match type. The match type controls how the key is compared.
| Match type | Behavior | Requirement |
|---|---|---|
| 0 | Exact match only | None |
| 1 | Largest value less than or equal to the key | Range sorted ascending |
| -1 | Smallest value greater than or equal to the key | Range sorted descending |
For key-based retrieval of assumptions, always type the 0. If you omit the argument, Excel uses 1. On an unsorted list, that setting can return a wrong position with no error at all.
Match type 1 has a legitimate use for tier tables, covered in a later chapter. For now, treat 0 as the default you always write.
Why modelers use INDEX with MATCH
XLOOKUP is shorter, so why learn this pattern at all? There are practical reasons.
- Compatibility. INDEX and MATCH exist in every version of Excel and in other spreadsheet programs. XLOOKUP needs Excel 2021 or Microsoft 365. A model sent to a lender or auditor on an older version will show errors in XLOOKUP cells.
- Return range is independent. The lookup column and the return column are separate arguments, so the return column can sit left or right of the key. This is also true of XLOOKUP, but it is not true of VLOOKUP, which is why INDEX/MATCH became popular.
- Position reuse. You can calculate the position once and feed it to several INDEX formulas. This is covered below.
- Existing models. You will inherit models built this way. Reading the pattern quickly is a practical skill.
The cost is readability. Two functions with two range arguments are harder to scan than one XLOOKUP, and the ranges must be kept aligned by hand.
A worked example
Consider an assumptions sheet with keys in column B and values in column C.
| Row | B (Key) | C (Value) | D (Unit) |
|---|---|---|---|
| 3 | Revenue growth | 0.08 | % |
| 4 | Gross margin | 0.62 | % |
| 5 | Tax rate | 0.25 | % |
| 6 | Opening cash | 150000 | USD |
On the model sheet, cell A5 contains Tax rate. To retrieve the rate:
=INDEX(Assumptions!$C$3:$C$6, MATCH($A5, Assumptions!$B$3:$B$6, 0))MATCH returns 3, and INDEX returns the third cell of C3:C6, which is 0.25.
To also retrieve the unit, change only the return range:
=INDEX(Assumptions!$D$3:$D$6, MATCH($A5, Assumptions!$B$3:$B$6, 0))The lookup range and key are unchanged. Only the column you read from differs.
Reusing the position in a helper column
When one key drives several retrievals, put MATCH in its own cell and point the INDEX formulas at it. If E5 holds the position:
=MATCH($A5, Assumptions!$B$3:$B$12, 0)Then each retrieval is short:
=INDEX(Assumptions!$C$3:$C$12, $E5)This has two benefits. The model searches the key list once instead of several times, which matters on large sheets. It also means a missing key produces one #N/A in the helper cell, which is easy to find, instead of the same error scattered across many cells. The trade-off is an extra column that readers must understand, so label it clearly, for example "Row position".
Anatomy of the formula
Read the formula from the inside out, which is also the order Excel calculates it.
The diagram shows that INDEX never sees the key. It only receives a position and a range. This explains why misaligned ranges produce wrong answers rather than errors: INDEX trusts whatever number MATCH gives it.
Common errors and what they mean
#N/A. MATCH found no exact match. Typical causes are a typo, a trailing space in either the key or the list, or a number stored as text in one place and as a number in the other. UseTRIMon imported text, or fix the source.- A plausible but wrong value. The ranges are misaligned, for example
C4:C13againstB3:B12. Every result is shifted by one row. Compare the first and last rows of both ranges. #REF!. The position is larger than the return range, which happens when the return range is shorter than the lookup range. It also happens if rows were deleted so the references collapsed.- The first of several matches. If the key appears twice, MATCH returns the first position and ignores the second. There is no warning. The next chapters cover how to detect this with COUNTIF.
- Ranges that shift when copied. If you forget the dollar signs,
B3:B12becomesB4:B13when filled down, and the lookup silently loses its first row. Anchor both ranges with$.
Handling a missing key
By default a missing key gives #N/A. In a financial model that is often what you want, because it makes the problem visible and stops it feeding through to totals. Wrapping every lookup in IFERROR hides real problems, because it also catches typos in the formula itself.
If you need a readable message, use IFNA, which catches only #N/A:
=IFNA(INDEX(Assumptions!$C$3:$C$12, MATCH($A5, Assumptions!$B$3:$B$12, 0)), "Missing assumption")Be careful with a numeric fallback such as 0. A zero tax rate or zero growth rate looks like a valid input, and the model will calculate without complaint. Text is safer because it breaks downstream arithmetic loudly.
Comparing with XLOOKUP
The same retrieval written both ways:
=XLOOKUP($A5, Assumptions!$B$3:$B$12, Assumptions!$C$3:$C$12, "Missing assumption")=IFNA(INDEX(Assumptions!$C$3:$C$12, MATCH($A5, Assumptions!$B$3:$B$12, 0)), "Missing assumption")XLOOKUP defaults to exact matching, has a built-in not-found argument, and is shorter. INDEX/MATCH requires you to write the 0 and the wrapper yourself. In exchange you get compatibility with older Excel and the ability to reuse the position. Choose by who will open the file, not by habit.
Summary of the pattern
- MATCH returns a position. INDEX returns the value at that position.
- The lookup range and return range must have the same size and start on the same row.
- Always write
0as the third MATCH argument for exact matches. - Anchor both ranges with
$before filling the formula down. - Prefer a visible
#N/Aor a text fallback to a silent zero.
Exercise
A model uses =INDEX(Assumptions!$C$4:$C$13, MATCH($A5, Assumptions!$B$3:$B$12, 0)). The key Gross margin is the second item in B3:B12. Which row's value does the formula return, and what should be changed?
Show answer
MATCH returns 2, so INDEX returns the second cell of C4:C13, which is C5. The key sits on row 4 of the lookup range, so the correct value is in C4. The ranges are misaligned by one row. Change the return range to Assumptions!$C$3:$C$12 so it starts on the same row as the lookup range.
Exercise
A colleague's MATCH formula is =MATCH($A5, Assumptions!$B$3:$B$12) and the list of keys is not sorted. Name the problem and give the corrected formula.
Show answer
The third argument is missing, so Excel uses match type 1, which expects an ascending sorted list and may return a wrong position without any error. The corrected formula is =MATCH($A5, Assumptions!$B$3:$B$12, 0).