Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    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

    Hope this is helpful

    francis, <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

    My Reading

    Pivot Table 101
    Pivot Table

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 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.
    With Worksheets("MyData")
    lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
    End With
    The first instruction will always refer to the currently active sheet.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts