Get the last value in a column
Updated · Checked on a live sheet · Excel and Google Sheets
The formula
=XLOOKUP(TRUE, F2:F13<>"", F2:F13, , 0, -1) returns the last non-empty value in F2:F13, even when some cells are blank. It looks for TRUE in a column of “is this cell filled?” answers, searching from the bottom up (search mode -1). It needs Excel 2021 or later, Microsoft 365 or Google Sheets.
In general: =XLOOKUP(TRUE, range<>"", range, , 0, -1)
Try it on a live sheet
| A | B | C | D | E | F | G | H | I | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | Ticket | Opened | Closed | Agent | Priority | Rating | Last rating | 5 | |
| 2 | T-101 | 1 Apr 2026 | 2 Apr 2026 | Mara | High | 5 | |||
| 3 | T-102 | 1 Apr 2026 | 6 Apr 2026 | Jonas | Low | 3 | |||
| 4 | T-103 | 2 Apr 2026 | 2 Apr 2026 | Priya | High | 4 | |||
| 5 | T-104 | 3 Apr 2026 | 9 Apr 2026 | Mara | Medium | 2 | |||
| 6 | T-105 | 3 Apr 2026 | Jonas | High | |||||
| 7 | T-106 | 6 Apr 2026 | 7 Apr 2026 | Priya | Low | 5 | |||
| 8 | T-107 | 7 Apr 2026 | 10 Apr 2026 | Mara | Medium | 4 | |||
| 9 | T-108 | 8 Apr 2026 | 8 Apr 2026 | Jonas | High | 5 | |||
| 10 | T-109 | 9 Apr 2026 | 15 Apr 2026 | Priya | Medium | 3 | |||
| 11 | T-110 | 10 Apr 2026 | Mara | Low | |||||
| 12 | T-111 | 13 Apr 2026 | 14 Apr 2026 | Jonas | Medium | 4 | |||
| 13 | T-112 | 14 Apr 2026 | 16 Apr 2026 | Priya | High | 5 |
I1 shows 5: the rating of ticket T-112, the last row of column F that has a value. The blank ratings for the still-open tickets T-105 and T-110 are skipped.
Why it works
Looks for TRUE in F2:F13 is not equal to empty text ("") and returns the value in the same position of F2:F13. If there's no match, it shows empty text (""). It searches from the last row up, so it finds the last match.
- 1. XLOOKUP: Looks for
TRUEinF2:F13is not equal to empty text ("") and returns the value in the same position ofF2:F13. If there's no match, it shows empty text (""). It searches from the last row up, so it finds the last match.
No gaps: INDEX with COUNTA
When the column has no blank cells, count the filled cells and take that position: INDEX(A2:A13, COUNTA(A2:A13)) returns the last ticket number. It works in every Excel version, but a blank in the middle makes it return the wrong row, because COUNTA then comes up short.
=INDEX(A2:A13,COUNTA(A2:A13))The last value that meets a condition
Swap the “is it filled” test for any condition: XLOOKUP("Mara", D2:D13, B2:B13, , 0, -1) returns the date Mara's most recent ticket was opened, because search mode -1 starts from the bottom.
=XLOOKUP("Mara",D2:D13,B2:B13,,0,-1)When you need it
You need the last value whenever a sheet grows downwards: the latest balance in a running ledger, the most recent reading in a log, the current status of an order with a history of updates, the last price someone paid. Typing a fixed cell like F13 breaks as soon as a row is added, while these formulas keep finding the end. If rows can be sorted differently later, decide whether you want the last row or the latest date; for the latest date, MAXIFS or a lookup on the date is safer than position.
In Google Sheets
Google Sheets has XLOOKUP with the same arguments, including search mode -1, so the main formula works there unchanged. INDEX with COUNTA works in both apps too.
Common mistakes
Using COUNTA on a column with gaps: it counts filled cells, so the position falls short of the real last row.
Forgetting the -1 search mode, which makes XLOOKUP return the first filled value instead of the last.
Pointing at a whole column (
F:F) that includes the header, so an empty column returns the header text.
Sources
Official documentation the facts on this page were checked against.