+ Reply to Thread
Results 1 to 6 of 6

Help with formula referencing a variable table range

Hybrid View

  1. #1
    Registered User
    Join Date
    12-17-2012
    Location
    us
    MS-Off Ver
    excel 2010
    Posts
    8

    Help with formula referencing a variable table range

    Hi all,
    Thoughts on what formula could accomplish the following?

    I have two tables tableA and tableB

    I want to do a vlookup in EITHER tableA OR tableB depending upon a cells value (value will be either A or B - the suffix of the table name)

    How do I make excel recognize I am looking to reference a table name and not the cell value?

    A1:B2 = TableA
    A4:B5 = TableB

    D3 = my lookup_value
    D4 = "A"

    The result I'm looking for is "=vlookup(D3,"Table"&D4,2,0) ....where "Table"&D4 will reference TableA

    Thank you for your help!!

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Help with formula referencing a variable table range

    Hello and welcome to the forum.

    Try this:

    =VLOOKUP(D3,INDIRECT("Table"&D4),2,0)

  3. #3
    Registered User
    Join Date
    12-17-2012
    Location
    us
    MS-Off Ver
    excel 2010
    Posts
    8

    Re: Help with formula referencing a variable table range

    Wow... I swear I tried INDIRECT, but kept getting #REF. I appreciate your quick response. That worked PERFECTLY!!!!!!

  4. #4
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Help with formula referencing a variable table range

    You're welcome. Thanks for the rep!

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Help with formula referencing a variable table range

    Try:

    =VLOOKUP(D4,INDIRECT("Table"&D3),2,FALSE)

    Edit: who forgot to refresh after getting a coffee....
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  6. #6
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Help with formula referencing a variable table range

    Quote Originally Posted by Glenn Kennedy View Post
    Edit: who forgot to refresh after getting a coffee....
    That'll teach you to get a coffee.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Referencing an Excel Table from a variable in VBA
    By Alpana Savarna in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-18-2014, 10:48 PM
  2. use variable for table range in a formula
    By gwminkl in forum Excel General
    Replies: 6
    Last Post: 01-29-2012, 10:10 AM
  3. referencing range w/ variable
    By dej222 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2009, 08:18 PM
  4. Referencing variable Range in a loop
    By Samirkc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-14-2006, 07:55 AM
  5. Re: Help with referencing variable range
    By Tom Ogilvy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-05-2005, 08:45 PM
  6. Help with referencing variable range
    By Cutter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-04-2005, 05:20 PM
  7. [SOLVED] Re: Help with referencing variable range
    By Gary Keramidas in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-04-2005, 05:10 PM

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