XLOOKUP vs INDEX MATCH: speed, safety and compatibility

This is not tax, legal, or lending advice. The rates below are statewide general sales-tax rates. A city rate is often higher, and this sheet does not look one up.

The five rows are the same sample as the XLOOKUP, XMATCH, and XLOOKUP vs VLOOKUP pages. The source is the Tax Foundation table of state and local sales-tax rates as of January 1, 2026, State and Local Sales Tax Rates.

State Statewide rate
CA 7.25%
FL 6.00%
MA 6.25%
NY 4.00%
TX 6.25%

The cells store the rates as ratios. 6.25% is 0.0625.

XLOOKUP
=XLOOKUP(D2,A2:A6,B2:B6,"Add this state")
=XLOOKUP(D2,A2:A6,B2:B6,"Add this state")D3
Texas, exact match
ABCD
1StateRateLookup
2CA7.25%TX
3FL6.00%6.25%
4MA6.25%5
5NY4.00%6.25%
6TX6.25%5
A picture of the sheet, not a live calculator. Statewide rates only, from the Tax Foundation table of January 1, 2026. D2 holds TX. D3 is XLOOKUP. D4 is MATCH with 0, and that 5 is the position of TX. D5 is INDEX of that position. D6 is XMATCH, which also returns 5.

The same 6.25%, written two ways

D2 holds the letters TX. The codes in A2:A6 are in alphabetical order.

=XLOOKUP(D2, A2:A6, B2:B6, "Add this state")
=MATCH(D2, A2:A6, 0)
=INDEX(B2:B6, MATCH(D2, A2:A6, 0))
=XMATCH(D2, A2:A6)

XLOOKUP returns 6.25%. It searches A2:A6 and returns the matching row from B2:B6. The fourth argument is what a missing code returns. TX is in the list, so that argument sits unused.

MATCH with 0 returns a position, not the rate. TX is the fifth code, so the result is 5. INDEX then returns the fifth rate in B2:B6, which is 6.25%. The 0 is an exact match. XMATCH of TX is also 5. Its default match is exact, so the 0 can be omitted and the position stays 5.

The VLOOKUP comparison already moves the rate to the left of the code. INDEX and MATCH still return 6.25% there, because the search range and the return range are separate. XLOOKUP does the same thing for the same reason.

Georgia is where the default matters

GA is not one of the five codes. It sorts between FL and MA.

MATCH
=INDEX(B2:B6,MATCH(D2,A2:A6))
=INDEX(B2:B6,MATCH(D2,A2:A6))D4
Georgia is not in the list
ABCD
1StateRateLookup
2CA7.25%GA
3FL6.00%2
4MA6.25%6.00%
5NY4.00%Add this state
6TX6.25%#N/A
A picture of the miss. The five codes are in alphabetical order. GA sits between FL and MA. MATCH with the third argument left off returns 2, and INDEX then returns Florida's 6.00%. XLOOKUP returns the words. XMATCH returns #N/A.
=MATCH("GA", A2:A6)
=MATCH("GA", A2:A6, 1)
=INDEX(B2:B6, MATCH("GA", A2:A6))
=XLOOKUP("GA", A2:A6, B2:B6, "Add this state")
=XMATCH("GA", A2:A6)

The third argument of MATCH defaults to 1. That form wants an ascending list and returns the position of the largest value that is less than or equal to what you asked for. FL is that value, so MATCH returns 2. INDEX then returns 6.00%. The cell looks like a successful lookup of a state that is not in the table.

Passing 1 explicitly is the same call. Leaving the argument off is how the 6.00% gets into the sheet.

XLOOKUP’s default is an exact match. The GA formula returns the words Add this state. XMATCH has no argument for those words. An exact miss is #N/A.

TX hides the problem. The code is in the list, and the list is sorted, so MATCH of TX with the third argument left off still returns 5, and INDEX still returns 6.25%. The exact form and the approximate form agree. The miss is where they split.

WY sorts after TX. Approximate MATCH returns 5, and INDEX returns Texas’s 6.25%. Exact XLOOKUP of WY returns Add this state. AL sorts before CA. Approximate MATCH of AL is #N/A, because nothing in the list is less than or equal to AL. Exact XLOOKUP of AL returns the words as well.

The exact INDEX formula needs a wrapper if you want those words instead of #N/A:

=IFNA(INDEX(B2:B6, MATCH("GA", A2:A6, 0)), "Add this state")

IFNA replaces #N/A only. INDEX of row 9 in a five-row range is #REF!, and IFNA leaves that #REF! visible. IFERROR would replace both. IFNA is in Excel 2013 and later. Excel 2010 has IFERROR and does not have IFNA.

Asking XLOOKUP for the next smaller item is a different request. Match mode -1 means exact, or the next smaller item if nothing matches:

=XLOOKUP("GA", A2:A6, B2:B6, "Add this state", -1)
=XLOOKUP("WY", A2:A6, B2:B6, "Add this state", -1)
=XLOOKUP("AL", A2:A6, B2:B6, "Add this state", -1)

On this sorted list, GA returns Florida’s 6.00%. WY returns Texas’s 6.25%. The fourth argument is unused in both, because a smaller code exists. AL returns Add this state, because no code is smaller. The default match mode, 0, does not do this. You get Florida for Georgia only when the formula asks for the next smaller item.

What changes when the list is long

Five rows will not show a speed difference. This page did not time a workbook.

The default search walks from the first row toward the last. TX is the fifth code, so that walk reads all five. Microsoft’s XLOOKUP page documents a sixth argument, search mode. 1 is first to last. -1 is last to first. 2 is a binary search and needs the lookup column sorted ascending. -2 is a binary search and needs it sorted descending. Microsoft says an unsorted column with mode 2 or -2 returns invalid results.

=XLOOKUP("TX", A2:A6, B2:B6, "Add this state", 0, 2)
=XLOOKUP("TX", A2:A6, B2:B6, "Add this state", 0, -1)
=XLOOKUP("GA", A2:A6, B2:B6, "Add this state", 0, 2)

TX appears once, and the codes are sorted A to Z, so the binary search and the last-to-first search both return 6.25%. The exact binary search of GA returns Add this state.

A binary search keeps half of the remaining rows at each step. A full Excel column is 1,048,576 rows, which is 2 to the 20th, so that search is on the order of 20 steps. A first-to-last search of a code in the last row reads every row. The sort is part of the work. It pays when the column stays sorted and you look up many codes. It does not pay for one lookup of five states.

MATCH with the third argument left off is also a fast approximate search, and it also requires ascending order. On this list it is the formula that returns Florida for Georgia. Speed is not a reason to leave the 0 off. Exact MATCH, the form with 0, walks the list the way default XLOOKUP does.

Where each function exists

INDEX and MATCH are in current Excel, in Excel for the web, and in Google Sheets. Excel 2010 has both.

XLOOKUP and XMATCH are in Microsoft 365, Excel 2021, Excel 2024, Excel for the web, and Google Sheets. Excel 2016 and Excel 2019 return #NAME? for both. Microsoft’s function page says XLOOKUP is not available in those two versions.

A file that still has to open in Excel 2010, 2016, or 2019 should keep INDEX and MATCH. Pass 0.

Which one to keep

Use XLOOKUP when the workbook will be opened in Microsoft 365, Excel 2021, Excel 2024, or Excel for the web. The exact match is the default, a missing code can return words, and search mode 2 is there when a long lookup column is kept in ascending order.

Use INDEX and MATCH, with 0, when the file still has to open in an older Excel. Wrap the pair in IFNA when a missing code should be words and every other error should stay visible. The cell where a row label and a column label meet is xl.two.way.

An invoice number is the same shape of lookup. The invoice tracker looks up 1042 with INDEX and MATCH, and it shows what approximate MATCH does with a number that is not on the list.


More from the blog