Lookup

Find the last match in Excel (XLOOKUP last value)

XLOOKUP and VLOOKUP return the first match. To get the latest entry for a ticker, product or customer, search from the bottom up.

Excel 365/2021 (XLOOKUP); LOOKUP version works in all Excel

The formula

Excel 365 / Google SheetsExcelGoogle Sheets
=XLOOKUP(B9,B2:B7,C2:C7,"Not found",0,-1)
In E2 → 60,480
Any Excel versionExcel
=LOOKUP(2,1/(B2:B7=B9),C2:C7)
In E3 → 60,480
Date of the last matchExcelGoogle Sheets
=XLOOKUP(B9,B2:B7,A2:A7,,0,-1)
In E4 → Mar 5, 2026
✓ Tested. All 3 Excel results in this example were recalculated in LibreOffice Calc 25.2 and matched the values shown.

Worked example

Paste the data below into a blank sheet starting at cell A1 (or download the cheat sheet, where every example is set up). Highlighted cells hold the formulas and show the expected results.

ABCDE
1DateTickerPrice
2Mar 2, 2026BTC61,20060,480
3Mar 2, 2026ETH340060,480
4Mar 3, 2026BTC62,950Mar 5, 2026
5Mar 4, 2026ETH3525
6Mar 5, 2026BTC60,480
7Mar 5, 2026SOL142
8
9TickerBTC

How it works

0
match_mode 0 = exact match.
-1
search_mode -1 = search from last to first, so the bottom-most match wins.
LOOKUP(2,1/(…))
1/(TRUE/FALSE) gives 1 or #DIV/0!. LOOKUP can't find 2, so it returns the last 1, which is the last match.

Common errors and fixes

Why does the formula return #N/A?

No match, or (LOOKUP version) every test is an error. Add XLOOKUP's if_not_found argument.

Not the latest date?

"Last" means lowest row. If your data isn't sorted by date, use MAXIFS to get the latest date first.

Does this work in Google Sheets?

The formulas tagged "Google Sheets" work as-is. Formulas tagged only "Excel" may need ARRAYFORMULA or a different function in Sheets.