Last Row

M

m stroup

I have seen the threads on finding the last row and have copied/pasted the
code and typed the code in myself.

I keep getting "invalid outside procedure" when I debug. Do I need a
special library reference? If so, how do I discern which one?
 
J

Joel

Change the column letter Z below to the column that you are looking at

LastRow = Range("Z" & Rows.Count).End(xlup).Row

What this line does is used the built in constant Rows.Count to indicate the
last row of a worksheet which is 65536 for excel 2003. I may be more for
2007. So the line above goes to cell "Z65536" and moves up in the
spreadsheet (xlup) until it finds the first non-empty cell. People also use
the following equivalent statements

LastRow = Range("Z65536").End(xlup).Row
LastRow = Cells(Rows.Count,"Z").End(xlup).Row
LastRow = Cells(65536,"Z").End(xlup).Row
LastRow = Cells(Rows.Count,26).End(xlup).Row
LastRow = Cells(65536,26).End(xlup).Row
 
M

m stroup

Sorry, Joel. This was a duh error on my part. No procedure defined. Thanks
for the quick response!
 
F

franciz

a little bit late on this.
try using LastRow = Cells(Rows.Count, 26).End(xlUp).Row.
This should work in all version of Excel

regards, xlsops
 
Top