+ Reply to Thread
Results 1 to 4 of 4

Thread: Reference a Cell for Tab name in VLOOKUP Table Array

  1. #1
    Registered User
    Join Date
    05-27-2009
    Location
    Denver, Colorado, USA
    MS-Off Ver
    excel mac:2008
    Posts
    2

    Reference a Cell for Tab name in VLOOKUP Table Array

    Hello all -

    I am trying to do the following:

    Sheet 1 contains:

    Item Sheet 2
    ABC =vlookup(A2,'Sheet 2'!$A:$B,2,false)

    Sheet 2 contains:

    Item Data
    ABC 2

    I'm trying to get the vlookup to return the value "2"

    Right now, I'm manually entering the tab name in the vlookup function, even though it's contained in cell B1.

    The tabs are contained in the same workbook if that matters. Since this workbook is growing rather quickly, this is a painful process and doesn't feel very scalable. Since I'm using a mac, I need to do this with functions vs. macros. Does anybody know how I can reference a cell for the name of a tab in the vlookup function?

    I was thinking I could maybe somehow do this with the INDIRECT function but I'm stumped.

    I apologize if this wasn't clear but it seems to be a slightly convoluted question.

    Thanks in advance for the help.
    Last edited by gabem; 05-27-2009 at 03:19 PM.

  2. #2
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,228

    Re: Reference a Cell for Tab name in VLOOKUP Table Array

    Does your sheet2 tab really have a space in it? Sheet 2? That's not standard, and spaces in sheettabs make these formulas a little more confusing to look at....consider NOT having spaces.

    INDIRECT is the function you want.

    Without spaces in the tab name:
    =VLOOKUP(A2,INDIRECT($B$1&"!$A:$B"),2,FALSE)

    With spaces in the tab name:
    =VLOOKUP(A2,INDIRECT("'"&$B$1&"'!$A:$B"),2,FALSE)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    05-27-2009
    Location
    Denver, Colorado, USA
    MS-Off Ver
    excel mac:2008
    Posts
    2

    Re: Reference a Cell for Tab name in VLOOKUP Table Array

    THANK YOU!!!!

    I was just using it incorrectly. This should save me some time.

  4. #4
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,228

    Re: Reference a Cell for Tab name in VLOOKUP Table Array

    INDIRECT() used this way constructs a normal reference but does it one piece at a time. All the components have to be represented within the INDIRECT() brackets to resolve a normal cell or range reference.

    ==============

    If that takes care of your need, be sure to EDIT your original post (Go Advanced) and mark the PREFIX box [SOLVED].



    (Also, use the "scales" icon in our posts to leave Feedback, it is appreciated)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones count!)

+ 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.2.0