Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Oct 2008
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts
    [quote name='CFDguru' post='765387' date='14-Mar-2009 13:56']Can someone tell me how to fix the problem?[/quote]
    In the code you should replace the line
    MyUsedRange = .Address
    with
    Set MyUsedRange = Range(.Address)

  3. #3
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post
    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
    Jerry

Posting Permissions

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