In the current version of Excel, a good way to solve this problem is with the XLOOKUP function.

In older versions of Excel, you could use the LOOKUP function.

Both methods are explained below.

Excel formula: Get date associated with last entry

XLOOKUP function

TheXLOOKUP functionis a modern upgrade to the VLOOKUP function.

XLOOKUP is very flexible and can handle many different lookup scenarios.

Because B5:B16 contains 12 values, the expression returns anarraythat contains 12 TRUE and FALSE results.

Excel formula: Get last entry by month and year

In this array, the TRUE values in the array indicatenon-blankcells and the FALSE values indicateblankcells.

With thereturn_arrayprovided as B5:B16, XLOOKUP returns 15-Jun-23 as a final result.

Dealing with errors

If the last non-empty cell contains an error, the error will be ignored.

Excel formula: Get first non-blank value in a list

For more details, seeBoolean Algebra in ExcelandXLOOKUP with multiple criteria.

One solution is to use theLOOKUP function, which can handlearray operationsnatively.

This array becomes thelookup_arrayargumentin LOOKUP.

Excel formula: Lookup latest price

Thelookup_valueis given as the number 2.

This may seem baffling, but there is a good reason.

We are using 2 as a lookup value to force LOOKUP to scan to theend of the data.

Excel formula: Last row in numeric data

Since theresult_vectoris B5:B16, the final result is: 15-Jun-23.

When LOOKUP can’t find a match, it will match the next smallest value.

LOOKUP’s default behavior makes it useful for solving certain problems in Excel.

Excel formula: Last row in text data

XLOOKUP supports approximate and exact matching, wildcards (* ?)

for partial matches, and lookups in vertical or horizontal ranges….

Excel LOOKUP function

Excel XLOOKUP function