+ Reply to Thread
Results 1 to 4 of 4

vlookup with variable name

  1. #1
    Registered User
    Join Date
    06-28-2007
    Posts
    27

    vlookup with variable name

    Hi all,

    I'm trying to do a vlookup inside of a FOR Loop where the lookup value is the name of a sheet, which I've made into a variable. When the next count of the FOR Loop changes, so does the sheet name.

    The formula gives me an error as the lookup value requires the sheet name to be in quotations in order for it to return a value. I've tried every possible combination without any success. Below, I've inserted the code

    Please Login or Register  to view this content.
    Thanks in advance for any help you can provide.
    J.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: vlookup with variable name

    When using quotations literally you need to double up (or use Chr 34)

    Please Login or Register  to view this content.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: vlookup with variable name

    Hello yaju1120,

    Assuming SName is a string, you can add the quotes like this:
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    06-28-2007
    Posts
    27

    Re: vlookup with variable name

    DonkeyOte & Leith,

    You guys are awesome...I kept on trying to double up the quotations but using different syntax and it wouldn't work.

    Your code works to perfection!!!

    Thanks a bunch...
    J.

+ 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