Get the Last Value in a Column
To return the last filled cell in a column — the latest balance, the most recent date — search from the bottom with XLOOKUP, or use the classic LOOKUP trick that works in every version. Describe your column below and get the formula.
Free, no sign-up required · 5 free generations a day
Last updated
Describe your task, get the formula
Type what you need in plain English, or pick an example below. You get the formula, a step-by-step explanation, and a worked example.
Formulas for the last non-empty cell
=XLOOKUP(TRUE,A2:A1000<>"",A2:A1000,,0,-1)
=LOOKUP(2,1/(A2:A1000<>""),A2:A1000)
=INDEX(A2:A1000,COUNTA(A2:A1000))XLOOKUP with -1 as its last argument searches from the bottom up and stops at the first cell that is not empty. The LOOKUP version relies on LOOKUP returning the last match when it cannot find its target. INDEX with COUNTA is the simplest, but only correct when the column has no gaps.
Examples
Last non-empty cell, any version of Excel
=LOOKUP(2,1/(A2:A1000<>""),A2:A1000)The division gives 1 for filled cells and an error for empty ones. LOOKUP cannot find 2, so it settles on the last 1 and returns the value from that row.
Last number in a column
=LOOKUP(9.99E+307,B2:B1000)Searches for a number larger than any real value. LOOKUP returns the last numeric cell and ignores text and blanks.
Last value in Google Sheets
=INDEX(FILTER(A2:A1000,A2:A1000<>""),COUNTA(A2:A1000))FILTER removes the empty cells, and INDEX takes the final item of what is left. Works in Google Sheets and in Excel 365.
Common mistakes and how to fix them
INDEX with COUNTA returns the wrong row
The column has blank cells, so the count is smaller than the row position of the last value. Use the XLOOKUP or LOOKUP formula, which do not depend on the count.
The formula returns an empty-looking result
The last cell contains a formula that returns an empty string. Test for length instead: replace A2:A1000<>"" with LEN(A2:A1000)>0.
Whole-column references make the sheet slow
LOOKUP with A:A checks more than a million cells on every recalculation. Limit the range to a size the list will realistically reach.
Frequently asked questions
How do I get the row number of the last value instead?
Use =LOOKUP(2,1/(A2:A1000<>""),ROW(A2:A1000)). It returns the sheet row number of the last filled cell.
How do I get the last value in a row?
The same formulas work sideways. Replace the column range with a row range, for example =LOOKUP(2,1/(B2:Z2<>""),B2:Z2).
How do I get the last value that matches a condition?
Add the condition to XLOOKUP: =XLOOKUP(E2,A2:A1000,B2:B1000,,0,-1) returns the value from column B for the last row where column A equals E2.
Don't want to write it by hand?
Describe what you need in plain English and get a ready-to-use formula in seconds.
Try the formula generator