ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Last Row (https://www.excelbanter.com/excel-programming/416689-last-row.html)

m stroup

Last Row
 
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?
--
Teach me to fish! Thanks for the help.
Pax, M

joel

Last Row
 
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 stroup" wrote:

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?
--
Teach me to fish! Thanks for the help.
Pax, M


m stroup

Last Row
 
Sorry, Joel. This was a duh error on my part. No procedure defined. Thanks
for the quick response!
--
Teach me to fish! Thanks for the help.
Pax, M


"Joel" wrote:

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 stroup" wrote:

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?
--
Teach me to fish! Thanks for the help.
Pax, M


franciz

Last Row
 
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

"m stroup" wrote:

Sorry, Joel. This was a duh error on my part. No procedure defined. Thanks
for the quick response!
--
Teach me to fish! Thanks for the help.
Pax, M


"Joel" wrote:

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 stroup" wrote:

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?
--
Teach me to fish! Thanks for the help.
Pax, M



All times are GMT +1. The time now is 07:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com