Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|