CoreGPT
Microsoft 36514 min read

INDEX MATCH in Excel: 13 Formulas to Copy (Multiple Criteria, Two-Way Lookups, #N/A Fixes)

INDEX MATCH explained on one small sample table, with 13 worked formulas and their results: basic and look-left lookups, INDEX MATCH MATCH, multiple criteria, wildcards, the errors people hit, and how it compares with VLOOKUP and XLOOKUP.

INDEX MATCH in Excel: 13 Formulas to Copy (Multiple Criteria, Two-Way Lookups, #N/A Fixes)

INDEX MATCH is a two-function lookup: =INDEX(return_range, MATCH(lookup_value, lookup_range, 0)). MATCH finds the position of your value in one column, and INDEX returns the cell at that position in another column. It works in every version of Excel, looks left as easily as right, and doesn't break when someone inserts a column.

Every formula below uses the same small table, so you can paste it into a blank sheet at A1 and follow along.

ABCDE
1ProductSizeSKUStockPrice
2CapMK-10160$12.00
3T-ShirtMK-10242$14.00
4T-ShirtLK-10318$15.00
5HoodieMK-10425$38.00
6HoodieLK-1057$40.00
7JacketLK-10611$79.00

The formulas read what to look for from four input cells: H1 holds the SKU K-105, H2 the product Hoodie, H3 the size L, and H4 the column name Stock.

INDEX MATCH formulas at a glance

#What you wantFormulaResult
1Price for a SKU=INDEX(E2:E7, MATCH(H1, C2:C7, 0))$40.00
2Look left: product for a SKU=INDEX(A2:A7, MATCH(H1, C2:C7, 0))Hoodie
3Two-way lookup (INDEX MATCH MATCH)=INDEX(A2:E7, MATCH(H1, C2:C7, 0), MATCH(H4, A1:E1, 0))7
4Multiple criteria=INDEX(E2:E7, MATCH(1, (A2:A7=H2)*(B2:B7=H3), 0))$40.00
5Multiple criteria, no array entry=INDEX(E2:E7, MATCH(1, INDEX((A2:A7=H2)*(B2:B7=H3), 0, 1), 0))$40.00
6Message instead of #N/A=IFNA(INDEX(E2:E7, MATCH(H1, C2:C7, 0)), "Not found")$40.00 (Not found for K-999)
7Partial match (wildcard)=INDEX(E2:E7, MATCH("Jack*", A2:A7, 0))$79.00
8Closest value at or below=INDEX(C2:C7, MATCH(50, E2:E7, 1))K-105
9Item with the highest value=INDEX(A2:A7, MATCH(MAX(D2:D7), D2:D7, 0))Cap
10Whole row for a SKU=INDEX(A2:E7, MATCH(H1, C2:C7, 0), 0)Hoodie, L, K-105, 7, $40.00
11Sum a column picked by name=SUM(INDEX(A2:E7, 0, MATCH(H4, A1:E1, 0)))163
12Case-sensitive lookup=INDEX(E2:E7, MATCH(TRUE, EXACT(C2:C7, H1), 0))$40.00
13Last match instead of first=INDEX(C2:C7, XMATCH(H2, A2:A7, 0, -1))K-105

If your lookup doesn't fit one of these, describe it in plain words to our free Excel formula generator and it writes the formula for your own columns.

How INDEX MATCH works

Take formula 1 apart and each half is simple:

=MATCH(H1, C2:C7, 0)

This returns 5, because K-105 is the 5th cell in C2:C7. The 0 asks for an exact match.

=INDEX(E2:E7, 5)

This returns $40.00, the 5th cell in E2:E7. Put the first inside the second and you get the standard pattern:

=INDEX(E2:E7, MATCH(H1, C2:C7, 0))

Two rules keep it reliable:

  • Both ranges must start and end on the same rows (here 2 to 7). MATCH returns a position inside its range, not a row number of the sheet.
  • Always type the 0. If you leave it out, MATCH uses approximate match and can return the wrong row without any warning.

If you'll copy the formula down a column, lock the ranges: =INDEX($E$2:$E$7, MATCH(H1, $C$2:$C$7, 0)). Press F4 on Windows or Cmd+T on Mac while the cursor is in a reference to add the $ signs.

Look left (formula 2)

The return range can be anywhere, including to the left of the lookup column:

=INDEX(A2:A7, MATCH(H1, C2:C7, 0))

This returns Hoodie from column A for the SKU in column C. VLOOKUP can't do that, because it only returns columns to the right of the one it searches.

INDEX MATCH MATCH: a two-way lookup

Add a second MATCH and the formula picks the column for you as well as the row. This is the pattern people call INDEX MATCH MATCH:

=INDEX(A2:E7, MATCH(H1, C2:C7, 0), MATCH(H4, A1:E1, 0))

The first MATCH finds the row for K-105 (5). The second finds the column whose header matches H4, "Stock" (4). INDEX returns the cell where row 5 and column 4 of A2:E7 meet: 7. Type Price in H4 and the same formula returns $40.00.

Note that INDEX now gets the whole table (A2:E7), the row MATCH searches one column, and the column MATCH searches the header row. The header range must span the same columns as the table (A to E).

INDEX MATCH with multiple criteria

Hoodie appears twice and so does size L, so neither column identifies a row alone. To match on both at once, multiply the conditions:

=INDEX(E2:E7, MATCH(1, (A2:A7=H2)*(B2:B7=H3), 0))

Each condition produces a list of TRUE and FALSE values, one per row. Multiplying them turns the pair into 1 only where both are TRUE, and MATCH(1, ..., 0) finds that row. With Hoodie in H2 and L in H3, the only 1 is at position 5, so the result is $40.00.

Excel worksheet with the formula =INDEX(E2:E7,MATCH(1,(A2:A7=H2)*(B2:B7=H3),0)) in H6 returning $40.00; below the sheet, the two conditions are shown as rows of 0s and 1s, and their product has a single 1 at position 5, the Hoodie size L row

Add a third condition the same way: (A2:A7=H2)*(B2:B7=H3)*(D2:D7>0).

In Excel for Microsoft 365, Excel 2021 and later, and Excel for the web, press Enter as usual. In Excel 2019 and older this is an array formula: confirm it with Ctrl+Shift+Enter (Ctrl+Shift+Return on a Mac), and Excel adds curly braces around it. Don't type the braces yourself.

Multiple criteria without Ctrl+Shift+Enter (formula 5)

If the file will be used in older versions and you don't want to rely on people pressing the right keys, wrap the conditions in a second INDEX:

=INDEX(E2:E7, MATCH(1, INDEX((A2:A7=H2)*(B2:B7=H3), 0, 1), 0))

The inner INDEX handles the array on its own, so a plain Enter works in every version. The result is the same $40.00.

More INDEX MATCH examples

Show a message instead of #N/A (formula 6)

=IFNA(INDEX(E2:E7, MATCH(H1, C2:C7, 0)), "Not found")

With K-105 in H1 you get $40.00; type K-999 and you get Not found instead of #N/A. Prefer IFNA to IFERROR here: IFERROR hides every error, including real mistakes like a deleted range.

Partial match with wildcards (formula 7)

=INDEX(E2:E7, MATCH("Jack*", A2:A7, 0))

* stands for any number of characters and ? for exactly one, so "Jack*" finds Jacket and returns $79.00. Wildcards only work with text and with the 0 match type. To search for text typed in a cell, use MATCH("*"&H2&"*", A2:A7, 0).

Closest value at or below (formula 8)

=INDEX(C2:C7, MATCH(50, E2:E7, 1))

Match type 1 finds the largest value that is less than or equal to the lookup value. The highest price at or under $50 is $40.00, so the formula returns K-105. This only works when the lookup column is sorted in ascending order, as the Price column is here. Use it for tax bands, shipping tiers and grade scales.

Item with the highest or lowest value (formula 9)

=INDEX(A2:A7, MATCH(MAX(D2:D7), D2:D7, 0))

MAX finds the largest stock number (60), MATCH finds where it is, and INDEX returns the product: Cap. Swap MAX for MIN to get the item that is running out (Hoodie).

Return the whole row (formula 10)

=INDEX(A2:E7, MATCH(H1, C2:C7, 0), 0)

A column number of 0 means "all columns". In Microsoft 365 the result spills into five cells: Hoodie, L, K-105, 7, $40.00. In Excel 2019 and older, select five cells in a row first, type the formula, and press Ctrl+Shift+Enter.

Sum a column you pick by name (formula 11)

=SUM(INDEX(A2:E7, 0, MATCH(H4, A1:E1, 0)))

Here the row number is 0, so INDEX hands the whole matching column to SUM. With "Stock" in H4 the total is 163. It works with AVERAGE, MAX and COUNT too.

Case-sensitive lookup (formula 12)

MATCH treats "k-105" and "K-105" as the same text. When case matters, compare with EXACT:

=INDEX(E2:E7, MATCH(TRUE, EXACT(C2:C7, H1), 0))

It returns $40.00 for K-105 and #N/A for k-105. This is an array formula too, so use Ctrl+Shift+Enter in Excel 2019 and older.

Last match with XMATCH (formula 13)

MATCH always returns the first match. XMATCH, its newer version, can search from the bottom up:

=INDEX(C2:C7, XMATCH(H2, A2:A7, 0, -1))

The -1 at the end searches last to first, so for Hoodie you get K-105 (the last Hoodie row) instead of K-104. XMATCH also uses exact match by default. It needs Microsoft 365 or Excel 2021 or later.

INDEX MATCH vs VLOOKUP

Both of these return $40.00 for the SKU in H1:

=VLOOKUP(H1, C2:E7, 3, FALSE)
=INDEX(E2:E7, MATCH(H1, C2:C7, 0))

The difference shows when the sheet changes or the question gets harder:

VLOOKUPINDEX MATCH
Return a column to the leftNoYes
Someone inserts a column in the tableThe fixed column number (3) now points at the wrong columnRanges adjust, the result stays correct
Two-way lookupNeeds a MATCH inside it anywayBuilt for it
Multiple criteriaNeeds a helper columnYes, formulas 4 and 5
Easy to readEasier for beginnersTwo functions to learn
Works inEvery version of ExcelEvery version of Excel

On speed, you won't notice a difference in a normal workbook. Use VLOOKUP for a quick lookup to the right in a table that won't change, and INDEX MATCH for anything you'll keep.

INDEX MATCH vs XLOOKUP

If everyone who opens the file has Microsoft 365 or Excel 2021 or later, XLOOKUP does the common cases in one function:

=XLOOKUP(H1, C2:C7, E2:E7)
=XLOOKUP(1, (A2:A7=H2)*(B2:B7=H3), E2:E7)
=XLOOKUP(H1, C2:C7, XLOOKUP(H4, A1:E1, A2:E7))

These match formulas 1, 4 and 3 and return $40.00, $40.00 and 7. XLOOKUP is exact match by default and has a built-in "not found" argument. INDEX MATCH still wins when the file must open in Excel 2019 or older, where XLOOKUP shows #NAME?, and in patterns like formula 11 where you need a whole column back. See XLOOKUP vs VLOOKUP for the full comparison.

INDEX MATCH #N/A and other errors: quick fixes

What you seeMost likely causeFix
#N/AThe value isn't in the lookup range, often because of a stray space or a number stored as textCheck with =COUNTIF(C2:C7, H1), then clean the data (below)
#N/A for a value that is in the listThe 0 is missing, so MATCH runs an approximate match on a column that isn't sortedAdd , 0 as the last MATCH argument
A wrong value, no errorThe two ranges start on different rows (E2:E7 with C1:C7), or the 0 is missingMake both ranges cover the same rows, add , 0
#REF!MATCH returned a position outside the INDEX range (lookup range longer than the return range), or a referenced column was deletedMake the ranges the same size
#VALUE! or #N/A on formula 4 or 12Array formula entered with plain Enter in Excel 2019 or olderPress Ctrl+Shift+Enter, or use formula 5
#NAME?A misspelled function, or XMATCH, XLOOKUP or IFNA in a version that doesn't have itFix the name, or use MATCH and IFERROR
#SPILL! on formula 10The cells to the right aren't emptyClear them

Fixing #N/A when the value looks like it's there

  • Extra spaces. "K-105 " with a trailing space doesn't equal "K-105". For the lookup value, use MATCH(TRIM(H1), C2:C7, 0). If the spaces are in the table, clean that column with TRIM in a helper column and paste the results back as values.
  • Numbers stored as text. An ID typed as a number won't match the same ID stored as text. If the table holds text, look up H1&""; if the table holds real numbers and H1 is text, look up VALUE(H1).
  • Ranges that moved. When you copy a formula down without $ signs, C2:C7 becomes C3:C8, then C4:C9, and rows drop out of the search. Lock the ranges with $.
  • The value really is missing. If =COUNTIF(C2:C7, H1) returns 0, there is nothing to find. Wrap the formula in IFNA (formula 6) to show a clear message.

Excel 365 vs older versions, and Google Sheets

FormulasMicrosoft 365, Excel 2021 and later, Excel for the webExcel 2019 and olderGoogle Sheets
1, 2, 3, 5, 7, 8, 9, 11Press EnterPress EnterWork as written
4 and 12 (array)Press EnterCtrl+Shift+EnterIf you get an error, wrap the formula in ARRAYFORMULA( )
6 (IFNA)YesExcel 2013 and later; use IFERROR before thatYes
10 (whole row)Spills automaticallySelect the cells, then Ctrl+Shift+EnterSpills automatically
13 (XMATCH)YesNo, shows #NAME?Yes

INDEX and MATCH take the same arguments in Google Sheets, and Sheets has XLOOKUP and XMATCH as well, so a file that moves between the two keeps working.

Frequently Asked Questions

What is INDEX MATCH in Excel? It's a combination of two functions used as one lookup formula. MATCH finds the position of a value in a row or column, and INDEX returns the value at that position in another range: =INDEX(return_range, MATCH(lookup_value, lookup_range, 0)).

Is INDEX MATCH better than VLOOKUP? For anything beyond a simple lookup to the right, yes. It can look left, it survives inserted columns, and it handles two-way and multiple-criteria lookups. VLOOKUP is a little easier to read for a quick one-off.

How do I use INDEX MATCH with multiple criteria? Multiply one condition per column inside MATCH and look for 1: =INDEX(E2:E7, MATCH(1, (A2:A7=H2)*(B2:B7=H3), 0)). In Excel 2019 and older, confirm with Ctrl+Shift+Enter or use the version with a second INDEX (formula 5).

Why is my INDEX MATCH returning #N/A? MATCH can't find the lookup value. The usual causes are extra spaces, numbers stored as text, a missing 0 as the last MATCH argument, or a range that shifted when the formula was copied.

Can INDEX MATCH return multiple values? It can return a whole row or column (formula 10), but only for the first match. To list every matching row, use FILTER in Microsoft 365, for example =FILTER(A2:E7, A2:A7=H2).

Should I use INDEX MATCH or XLOOKUP? Use XLOOKUP when everyone has Microsoft 365 or Excel 2021 or later, because it's shorter. Use INDEX MATCH when the file has to work in older versions.

Let AI write the INDEX MATCH formula for you

Most INDEX MATCH problems come down to small details: a range that starts one row off, a missing 0, or a condition in the wrong place. CoreGPT for Excel lets you describe the result you need, such as "get the price for the product in H2 and the size in H3" or "flag each row as above or below target", and writes the formula into your sheet with a short explanation. It's free to start and works in Excel for Windows, Mac and the web.

Try it: CoreGPT for Excel

Related reading:

Free AI tools

Keep reading

Microsoft 365

How to Insert Multiple Rows in Excel (Shortcuts and Fixes)

Add several blank rows at once with the right-click menu, the Ctrl+Shift+= shortcut or Home → Insert, put a blank row between every row of your data, add rows inside an Excel table, and fix the errors that stop Excel from inserting rows.

Read more