To get the last non-empty value in a column, use =LOOKUP(2,1/(A:A<>""),A:A). It works by turning every filled cell into a 1 and every empty one into an error, then looking for 2 — which never exists, so LOOKUP falls back to the last valid number it found. That’s the last filled cell.
The same formula works across a row by swapping the references: =LOOKUP(2,1/(1:1<>""),1:1). If your data has no gaps and you know the range, =INDEX(A1:A20,ROWS(A1:A20)) is simpler, but it breaks the moment the last cell is empty.
In Excel 365 there’s a cleaner option: =XLOOKUP(TRUE,A2:A100<>"",A2:A100,,0,-1) — the -1 tells XLOOKUP to search from the bottom up, so it stops at the first non-blank it meets. Two variations worth knowing: =LOOKUP(9.99E+307,A:A) returns the last number in a column, and =LOOKUP(REPT("z",255),A:A) returns the last text value.
In Excel, there are two ways to look up the last value from a column or a row. In this tutorial, we will learn to use both formula types and try to cover them in different situations.
Lookup the Last Value (When the Last Value Is in the Last Cell)
Follow these steps to write this formula:
- First, enter the INDEX function in a cell.
- After that, in the array argument, refer to the range of values.
- Next, in the rows argument, enter the ROWS function.
- In the ROWS function, refer to the range where you have values.
- In the end, enter the closing parentheses and hit Enter to get the result.

=INDEX(A1:A4,ROWS(A1:A4))
The moment you hit Enter, it returns the value from the last cell of the range.

The only problem with this formula is when you don’t have a value in the last cell of the range. In that case, it returns 0 (the empty last cell), not the last value.

Therefore, we can switch to the formula we will discuss next.
Lookup Last Value in Column
You can use the LOOKUP function for this. And the formula will be:
=LOOKUP(2,1/(A:A<>""),A:A)
LOOKUP has two syntaxes to follow, and we have used the vector syntax.

(A:A<>””)
This part of the formula returns an array after testing whether a cell has a value.
Here we have referred to the entire column, and that’s why it has returned a large array. But in the first three values, you can see we have TRUE, which is because we have the values in the first three cells in column A.

1/(A:A<>””)
And when you divide 1 by the entire array returned by the earlier part of the formula, you get 1 for TRUE and #DIV/0! for all the FALSE values.

A:A
In this part of the formula, you have the reference to column A. And it returns an entire array of values from the column. Where the cell is blank, you have a 0, and the actual value where the cell is not blank.

LOOKUP(2,1/(A:A<>””),A:A)
As I mentioned earlier, we used the LOOKUP function’s vector syntax.

- In the LOOKUP vector, we have all the values as 1 and #DIV/0!: 1 where we have the values in the RESULT vector, and #DIV/0! where we don’t have any value in the result vector.
- When you look up 2 in a vector that only has 1s and errors, LOOKUP can’t find 2, so it ignores the errors and goes to the last 1 in the LOOKUP vector (the largest value that is less than or equal to 2).
- Then it returns the corresponding value from the result vector. That last value is the exact last value in column A.

Lookup for the Last Value from a Row
The same formula can be used to get the value from the last non-empty cell of a row. You only need to change the reference.

=LOOKUP(2,1/(1:1<>""),1:1)
In this formula, we have referred to the entire row (Row 1) for the lookup vector and the same in the result vector. And when you hit Enter, it returns the value from cell D1, which is the last non-empty cell in the row.
Referring to an entire column or row makes Excel check over a million cells, which can slow down a big workbook. If you know where your data ends, use a fixed range like A1:A1000 instead. Also, a cell with a formula that returns “” doesn’t count as a value for this formula, so it’s skipped.
Get the Row Number of the Last Value
If you need the position of the last value instead of the value itself, use ROW in the result vector:
=LOOKUP(2,1/(A:A<>""),ROW(A:A))
Last Number or Last Text Value
When you only want the last number in a column, look up a number that is bigger than any number Excel can hold. LOOKUP can’t find it, so it returns the last number in the column:
=LOOKUP(9.99999999999999E+307,A:A)
And for the last text value, look up a text that sorts after any other text. Note that a formula that returns “” also counts as text here:
=LOOKUP(REPT("z",255),A:A)
Use XLOOKUP or TAKE in Microsoft 365
In Excel 2021 and Microsoft 365, XLOOKUP can search from the bottom with -1 in its search_mode argument. The following formula looks for the first non-empty cell from the bottom of A1:A1000:
=XLOOKUP(TRUE,A1:A1000<>"",A1:A1000,,0,-1)
And in Microsoft 365, you can also filter out the blank cells and take the last one with TAKE:
=TAKE(FILTER(A1:A1000,A1:A1000<>""),-1)
Frequently Asked Questions
How do I get the last value that matches a condition?
Put the condition in the lookup vector. For example, this returns the last amount from column B where column A has “East”:
=LOOKUP(2,1/(A1:A1000="East"),B1:B1000)
Why does the formula return #N/A?
There’s no cell that meets the condition, so the lookup vector has only errors. Wrap the formula in IFERROR if the range can be empty.
Do I need to press Ctrl + Shift + Enter?
No. LOOKUP handles arrays on its own, so the LOOKUP(2,1/…) formula works with a normal Enter in all versions of Excel.
Thank you, a great help
Glad to hear that, Paul.