#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"