A normal lookup returns the first match from the top. When rows are in date order and you want the latest entry — the most recent price, the last status — you need to search from the bottom up.
-1 is search_mode: search last-to-first, so the newest matching row wins.
The example
An order log in date order. We want Acme’s most recent amount.
| A | B | C | |
|---|---|---|---|
| 1 | Customer | Date | Amount |
| 2 | Acme | 1/05 | $120 |
| 3 | Bolt | 2/03 | $80 |
| 4 | Acme | 3/18 | $200 |
| 5 | Acme | 5/30 | $260 |
| 6 | Bolt | 6/01 | $90 |
The formula
Acme’s latest amount:
How it works
The search direction is everything:
- The first three arguments are an ordinary exact-match lookup of "Acme".
- The 5th argument,
match_mode 0, keeps it an exact match. - The 6th argument,
search_mode -1, tells XLOOKUP to scan from the bottom up, so the first hit it finds is the last one in the list. - With the log in date order, that last hit is the most recent —
$260.
Try it: interactive demo
Pick a customer and a direction; see which amount XLOOKUP returns.
Variations
Legacy LOOKUP trick (any version)
The classic way to get the last match before XLOOKUP:
Last match by date, unsorted data
If rows aren’t in date order, find the max date for that customer first:
Pitfalls & errors
"Most recent" assumes date order. search_mode -1 returns the last row, which is only the newest if the data is sorted by date. If not, sort first or use the MAXIFS approach.
The LOOKUP(2,1/…) trick looks odd but is reliable. Dividing 1 by a TRUE/FALSE array makes non-matches errors; LOOKUP ignores errors and returns the last valid (last matching) value.
search_mode is the 6th argument. Don’t confuse it with match_mode (5th). Leave match_mode at 0 and set search_mode to -1.
Practice workbook
Frequently asked questions
How do I get the last match in Excel?
How does LOOKUP(2,1/(range=value)) work?
How do I get the most recent value by date if data isn't sorted?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class