Function · Lookup
Excel XLOOKUP function
The Excel XLOOKUP function finds a value and returns a matching cell, with a message when nothing matches. A state tax-rate example and the versions that have it.
Syntax =XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
=XLOOKUP(D2,A2:A6,B2:B6,"Add this state")Arguments
| Name | Required | What to pass |
|---|---|---|
| lookup_value | Required | The value to find. |
| lookup_array | Required | The row or column to search. It does not have to be to the left of the result. |
| return_array | Required | The row or column to return from. It must be the same length as lookup_array. |
| if_not_found | Optional | What to return when there is no match. If omitted, a miss is #N/A. |
| match_mode | Optional | 0, the default, is an exact match. -1 and 1 are the next smaller or next larger item. 2 allows wildcards. |
| search_mode | Optional | 1 searches first to last. -1 searches last to first. 2 and -2 are binary searches and require the lookup array to be sorted. |
Examples
Texas statewide rate, with a message ready for a missing state
=XLOOKUP("TX",A2:A6,B2:B6,"Add this state")Result 6.25%
| A | B | C | D | |
|---|---|---|---|---|
| 1 | State | Rate | Lookup | |
| 2 | CA | 7.25% | TX | |
| 3 | FL | 6.00% | 6.25% | |
| 4 | MA | 6.25% | ||
| 5 | NY | 4.00% | ||
| 6 | TX | 6.25% |
XLOOKUP separates the column you search from the column you return, so the answer can sit to the left of the key. The default is an exact match. You do not have to remember to pass FALSE, which is the mistake VLOOKUP invites. A fourth argument is the result when the key is missing. Looking up WY in the five-state table returns Add this state instead of #N/A.
The Texas result is the statewide 6.25% from the Tax Foundation table of January 1, 2026. It is not a city rate. The sales-tax LAMBDA is what you use once you already have the rate and only need it rounded to the cent.
Excel 2016 and 2019 do not have this function. A workbook that has to open there should keep VLOOKUP, or INDEX and MATCH. Binary search (search_mode 2 or -2) is faster on a long sorted list and wrong on an unsorted one. Leave search_mode out unless you have sorted the key on purpose. An https picture address in the return column is text. IMAGE places that picture in the cell.