Results 1 to 2 of 2
Thread: Last Rows (Xls 2003)
2007-12-22, 19:35 #1
- Join Date
- Nov 2005
- Asia Pacific, Bangkok Metropolis
- Thanked 0 Times in 0 Posts
Last Rows (Xls 2003)
I have approximately 40 sheets in a workbook, I want to delete those sheets with the last rows contain number less 10 in column C.
what is the differences between these :
1) lastrow = Range("A65536").End(xlUp).Select
2) lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
2007-12-22, 19:46 #2
- Join Date
- Mar 2002
- Thanked 29 Times in 29 Posts
Re: Last Rows (Xls 2003)
The first instruction isn't correct. Range("A65536").End(xlUp).Select selects a cell, it doesn't return a value you can assign to lastrow. It should be
lastrow = Range("A65536").End(xlUp).Row
With this change, it is equivalent to the second instruction in Excel 97 to Excel 2003. In Excel 2007, however, the number of rows in a spreadsheet is much larger than 65536. The second instruction will work correctly in all versions of Excel, the first would assign an incorrect version to lastrow if more than 65536 rows are used.
One other point: the second instruction must be used in a With ... End With block, e.g.
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
The first instruction will always refer to the currently active sheet.