1LOOKUP(2, 1/(...))
=LOOKUP(2,1/(B2:B15<>""),B2:B15)
- Type =LOOKUP(2,1/(B2:B15<>""),B2:B15) in an empty cell.
- Make the range reach past the last row you expect to use.
Return the last non-blank value in a column with LOOKUP, XLOOKUP searching from the bottom, or INDEX, so the result updates when you add rows.
A log grows by a row every day and you want a cell that always shows the latest entry, the closing balance or the most recent reading, without editing the formula each time.
The idea is to find the position of the last filled cell, then return the value at that position. The shortest formula that does it in one step is:
=LOOKUP(2, 1/(B2:B15<>""), B2:B15)
B2:B15<>"" tests every cell and returns TRUE for the non-blank ones. Dividing 1 by TRUE/FALSE gives 1 for filled cells and #DIV/0! for blanks. LOOKUP is searching for 2, which is bigger than anything in the list, so it settles on the last number it can see, the last filled position. It ignores the errors. Then it returns the matching item from the third argument. It is a well-known trick, and it works in every version.
XLOOKUP expresses the same idea more clearly by searching from the bottom: =XLOOKUP(TRUE, B2:B15<>"", B2:B15, , 0, -1). The last argument, -1, means search from last to first.
INDEX(B2:B15, COUNT(B2:B15)) also works, but only when the data is contiguous, with no gaps, because it assumes the last value sits at position COUNT.
Choose a range that reaches past your data, to row 15 here, so new rows are picked up. If you point at a whole column such as B:B, make sure the heading is text and any totals below are not in that column.
For a quick manual jump, select a cell in the column and press Ctrl+Down Arrow to move to the last cell in the block. The formulas above are for cells that must update by themselves. The Lookups track covers more lookup patterns.
=LOOKUP(2,1/(B2:B15<>""),B2:B15)
=XLOOKUP(TRUE,B2:B15<>"",B2:B15,,0,-1)
=INDEX(B2:B15,COUNT(B2:B15))
Solve it in the sheet. Every answer is checked, with hints if you need them.
Task 1 of 2
In D2, return the last balance entered in B2:B15. Rows 10 to 15 are still empty, and the formula must pick up new entries.
Answer in D2.
Excel foundations covers this in lesson 7, COUNT and COUNTA.