Specify last row

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
I want to specify the last row in a table, but can only remember how to do it if the table starts in "A1".

Code:
lngLastRow = Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row

However in my worksheet "A1" is blank, and the table starts at "A2"
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
In code? Try

Code:
LR = Range("A" & Rows.Count).End(xlUp).Row

Edit: I see you added your code as I posted.
 
Last edited:
Upvote 0
That code will still give you the last row of column A.
Regardless if A1 is blank or not.
 
Upvote 0
Yeah, which is why I couldn't work out what was wrong with it.

Just realised that I was clearing the cells before specifying the last row, which is why is wasn't returning what I expected. Have just rearranged the code now and it works fine. Silly mistake. Thanks for answering anyway
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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