VBA · Original teaching example
VBA: find the last used row
This teaching case was authored to show a note format. It was not extracted from a real video or user note, and it has no invented timestamps.
Problem
Find the last non-empty row in a known worksheet column before processing a table.
Approach and limits
Start at the bottom of column A and move upward. An empty column returns row 1, so check the header or data range before treating it as a record.
Example code
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).RowCheck it yourself
With values in A1 and A4, the result should be 4. Clear A4 and check that the result changes to 1.