+ Reply to Thread
Results 1 to 8 of 8

Better way of finding last row on sheet

  1. #1
    Andibevan
    Guest

    Better way of finding last row on sheet

    Hi,

    Can anyone improve on this formula to find the last row of a sheet:-

    Sheet1.Range("A65536").End(xlUp).Row

    This keeps finding row 26 as the last row when I only have 3 rows of data.

    Any ideas?

    Andi



  2. #2
    Registered User
    Join Date
    09-16-2004
    Location
    Virginia
    Posts
    46
    Do you have formulas in cells 4 thru 26? This would cause your problem.

    You could also do something like

    Please Login or Register  to view this content.
    HTH
    Tom Stock
    Office version: MSO 2002 SP3
    OS: Windows XP Pro
    Hardware: IBM Thinkpad T41

  3. #3
    Jim Cone
    Guest

    Re: Better way of finding last row on sheet

    Andi,

    Did you check cell A26 to see if it had a space or some non-printing character in it?

    Regards,
    Jim Cone
    San Francisco, USA


    "Andibevan" <[email protected]>
    wrote in message news:[email protected]...
    Hi,
    Can anyone improve on this formula to find the last row of a sheet:-
    Sheet1.Range("A65536").End(xlUp).Row
    This keeps finding row 26 as the last row when I only have 3 rows of data.
    Any ideas?
    Andi



  4. #4
    Roman
    Guest

    Re: Better way of finding last row on sheet

    Hi Andibevan,

    I guess that the last cell is really in 26th row.
    This should select it (the same as Ctrl+End)

    sub selectlastcell()
    Cells.SpecialCells(xlCellTypeLastCell).select
    end sub

    Save your work and use this to recover your really last cell:
    (this will reset the undo operations memory!)

    sub recoverlastcell()
    ActiveSheet.UsedRange
    end sub


  5. #5
    Jef Gorbach
    Guest

    Re: Better way of finding last row on sheet


    "Andibevan" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > Can anyone improve on this formula to find the last row of a sheet:-
    >
    > Sheet1.Range("A65536").End(xlUp).Row
    >
    > This keeps finding row 26 as the last row when I only have 3 rows of data.
    >
    > Any ideas?
    >
    > Andi
    >
    >


    sounds likes cell(A26) an "invisible" space/etc character ??



  6. #6
    Bob Phillips
    Guest

    Re: Better way of finding last row on sheet


    "Andibevan" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > Can anyone improve on this formula to find the last row of a sheet:-
    >
    > Sheet1.Range("A65536").End(xlUp).Row
    >
    > This keeps finding row 26 as the last row when I only have 3 rows of data.


    I very much doubt it, this technique doesn't suffer the last used cell
    problem that say Ctlr-End suffers. You must have something in A26. Try
    ?LEN(Range("A26")) in the immediate window



  7. #7
    Andibevan
    Guest

    Re: Better way of finding last row on sheet

    Thank-you all for your very helpful comments - I was missing the obvious (as
    usual).

    There was some hidden text in row 26 - now works fine

    Thanks all

    "Bob Phillips" <[email protected]> wrote in message
    news:[email protected]...

    "Andibevan" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > Can anyone improve on this formula to find the last row of a sheet:-
    >
    > Sheet1.Range("A65536").End(xlUp).Row
    >
    > This keeps finding row 26 as the last row when I only have 3 rows of data.


    I very much doubt it, this technique doesn't suffer the last used cell
    problem that say Ctlr-End suffers. You must have something in A26. Try
    ?LEN(Range("A26")) in the immediate window




  8. #8
    Ashman
    Guest

    RE: Better way of finding last row on sheet

    The first question is, is there anything in cell a26? This procedure will
    stop at anything

    Ashman

    "Andibevan" wrote:

    > Hi,
    >
    > Can anyone improve on this formula to find the last row of a sheet:-
    >
    > Sheet1.Range("A65536").End(xlUp).Row
    >
    > This keeps finding row 26 as the last row when I only have 3 rows of data.
    >
    > Any ideas?
    >
    > Andi
    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1