Finding the last row dynamically

Solved/Closed
J - May 4, 2010 at 01:19 PM
 J - May 4, 2010 at 03:19 PM
Hi,
I am using VBA in Excel 2007. I have a worksheet which has multiple columns. Each column has different number of rows.
I want to find the last row in each column.

Currently, I used the following code and I cannot get the last row location beyond column A.
Please help!
**********************************************************************
do while column_location <100
Set rnglast_test = Worksheets("test").Range("A1").Offset(column_location).SpecialCells (xlCellTypeLastCell)
last_row_text = rnglast_top_3.row
column_location = column_location + 1
loop

2 responses

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
May 4, 2010 at 01:30 PM
if you want to find last used row for each column then you can use this (example for column B)

lastrow = cells(rows.count, "B").end(xlup).row

or

lastrow = cells(rows.count, 2).end(xlup).row
1
Thank you very much for your help
0