Wauvel

Excel like a finance pro.

← The library

VBA · Ranges

Finding the last row

The standard way to find the last used row in a column, mimicking Ctrl + Up from the bottom.

Daily driverDifficulty 1150 · Proficient
Practice · 2 questions →

When to use it

The standard way to find the last used row: start at the bottom of the sheet and press Ctrl + Up in code with End(xlUp). Works even with blanks in the middle of the data.

The code

Code
lastRow = Cells(Rows.Count, 1).End(xlUp).Row

Worked examples

  • Last row

    lastRow = Cells(Rows.Count, 1).End(xlUp).Row The last used row in column A

    The pattern to memorize.

  • Last column

    lastCol = Cells(1, Columns.Count).End(xlToLeft).Column The last used column in row 1

    Same idea sideways.

  • Build the data range

    Set rng = Range("A2:C" & lastRow) The data block built from lastRow

    Then loop or read it.

Worth knowing

  • Pick a column that is always filled, like an ID column.
  • Qualify with a sheet: ws.Cells(ws.Rows.Count, 1).
  • UsedRange is unreliable for this; End(xlUp) is not.

Where it goes wrong

  • Returns 1 on an empty column, so a loop from 2 To lastRow runs zero times, which is usually fine.
  • Filtered or hidden rows are still counted.

Related

Learn the moves here — or let Wauvel run them on your numbers.

Meet your AI CFO →

One CFO-grade Excel tip a week

A short, practical email for finance operators — functions, shortcuts, and the moves that save an afternoon. Free, unsubscribe anytime.