formulastreak

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

Ratings in column F have gaps for open tickets; the formula still finds the last one · edit I1 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultI1 = 5
ABCDEFGHI
1TicketOpenedClosedAgentPriorityRatingLast rating5
2T-1011 Apr 20262 Apr 2026MaraHigh5
3T-1021 Apr 20266 Apr 2026JonasLow3
4T-1032 Apr 20262 Apr 2026PriyaHigh4
5T-1043 Apr 20269 Apr 2026MaraMedium2
6T-1053 Apr 2026JonasHigh
7T-1066 Apr 20267 Apr 2026PriyaLow5
8T-1077 Apr 202610 Apr 2026MaraMedium4
9T-1088 Apr 20268 Apr 2026JonasHigh5
10T-1099 Apr 202615 Apr 2026PriyaMedium3
11T-11010 Apr 2026MaraLow
12T-11113 Apr 202614 Apr 2026JonasMedium4
13T-11214 Apr 202616 Apr 2026PriyaHigh5

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. 1. XLOOKUP: 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.

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.

Practise XLOOKUP on a live sheet

Lesson 17, XLOOKUP (Unit 4, Lookups), has 4 graded exercises, checked instantly, with steps and hints when you're stuck. Pro