+ Reply to Thread
Results 1 to 4 of 4

Auto Determine Range to pass to vlookup

  1. #1
    Registered User
    Join Date
    08-17-2010
    Location
    Silver City, New Mexico
    MS-Off Ver
    Excel 2010
    Posts
    2

    Auto Determine Range to pass to vlookup

    Hello all,

    I'm trying to use vba to determine the range of a worksheet so that the range includes all data on the sheet.

    I've found the following code to determine the bottom, right most cell

    Please Login or Register  to view this content.
    The problem is that the function returns a string, not a range reference.
    i.e. if the 'ctrl-end' keystroke were to take me to cell 'AM68' the function returns a string
    '$AM$68'.

    It seems to me it should be a trivial process to turn the info into a range object, but I'm really struggling here. Any help would be appreciated.

    Once I have the range I want to replace the hard-coded range reference is the code below

    Please Login or Register  to view this content.
    Thanks in advance for your help.
    Last edited by captlogic; 08-17-2010 at 02:39 PM. Reason: SOLVED!

  2. #2
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: Auto Determine Range to pass to vlookup

    Try adding this to your code:

    Please Login or Register  to view this content.
    Let me know if that helps.

  3. #3
    Registered User
    Join Date
    08-17-2010
    Location
    Silver City, New Mexico
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Auto Determine Range to pass to vlookup

    Quote Originally Posted by BigBas View Post
    Try adding this to your code:

    Please Login or Register  to view this content.
    Let me know if that helps.

    I knew it would be trivial to do what I wanted, but I figured it would take more than 1 line of code!

    Your one line of code eliminated the need for the FindLastCell function!

    Thanks

  4. #4
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: Auto Determine Range to pass to vlookup

    Not a problem. Glad I could help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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