finding last row

ricksimm

Board Regular
Joined
Apr 28, 2005
Messages
188
i use the following to find the last row in column A.
Code:
        lbrowCNT = Range("A1", Range("A" & Rows.Count).End(xlUp)).Rows.Count
If I have columns A thru X and each column can have a different number of rows in use, can the above statement be modified to find the row count for the longest column? Or do I have to look at each column separately? Thanks.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
try

Code:
lr = ActiveSheet.UsedRange.Rows.Count + ActiveSheet.UsedRange.Row - 1

replace activesheet with an appropriate sheet name.
 
Upvote 0
This is better for just that case.


Code:
Dim LstRw As Long, c As Range
Set c = Cells.Find(What:="*", After:=Cells(1, 1), SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
If c Is Nothing Then
    LstRw = 1
Else
    LstRw = c.Row
End If

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,384
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top