• Last Cell in Worksheet

    Author
    Topic
    #458287

    I found a subroutine on the web which finds the last row and column cell address. I’ve attached a copy of the code in the attached worksheet. When I run this code I get an error. Can someone tell me how to fix the problem? Or, maybe suggest a simpler approach?

    Note that what I’m trying to do is to be able to select a table of values (strings and numbers) without selecting the title or any other empty cells or cell formatting that might have been left behind. I usually get the spreadsheet from other users who have put in the data, so it’s important for me to select only the listed data range so I can do data munipulation such as filtering and sorting.

    Thanks.

    Viewing 1 reply thread
    Author
    Replies
    • #1151928

      Can someone tell me how to fix the problem?

      In the code you should replace the line
      [indent]MyUsedRange = .Address
      [/indent]with
      [indent]Set MyUsedRange = Range(.Address)
      [/indent]

    • #1151929

      After Stuart’s fix the code actually finds C7 as the last cell which is wrong as B7 is!

      The attached code from Ozgrid finds the actual last used cell

      Last Used Cell

      Code you need is called FindLastCell

      HTH

    Viewing 1 reply thread
    Reply To: Last Cell in Worksheet

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: