+ Reply to Thread
Results 1 to 6 of 6

Dynamically refer to a table in a worksheet index/match function

  1. #1
    Registered User
    Join Date
    07-24-2015
    Location
    Toledo, OH
    MS-Off Ver
    Microsoft Office 2010
    Posts
    85

    Dynamically refer to a table in a worksheet index/match function

    Hi all,

    I want to be able to reference a table dynamically for an INDEX/MATCH function, and I want to base that reference on a cell value. For example, let's say I have four tables on a worksheet. Each have three columns, named "Column1", "Column2", and "Column3". The tables are named the following names:

    Table2016
    Table2017
    Table2018
    Table2019

    And let's say the function looks like this if I reference the table range directly as an array:

    =INDEX(Table2016, MATCH("Test", Table2016[Column1], 0), 3)

    What I want to be able to do is put a cell reference in the array reference for the INDEX portion and the same cell reference in the lookup array reference for the MATCH portion. So, just as a rough example, I would make the value of cell A1 equal "Table 2016" and then write something like this:


    =INDEX("=A1", MATCH("Test", "=A1"[Column1], 0), 3)

    I know this example does not work.

    Before anyone gives a possible answer, let me state the following: No, I cannot use macros for this because I have been asked not to use macros for the spreadsheet. No, I can't use a VLOOKUP instead because there will be times when I have to look at the last column and return a value from the first. I need to use worksheet functions only, and I need the function to be able to dynamically reference a table name if it's possible.

    Thanks!

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,231

    Re: Dynamically refer to a table in a worksheet index/match function

    Try this:

    =INDEX(INDIRECT(A1), MATCH("Test", INDIRECT(A1&"[Column1]"), 0), 3)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    07-24-2015
    Location
    Toledo, OH
    MS-Off Ver
    Microsoft Office 2010
    Posts
    85

    Re: Dynamically refer to a table in a worksheet index/match function

    That seems to work fine, but I'm concerned about using INDIRECT. I know it can really slow down computation, and there are going to be over a thousand of these references in the worksheet.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,231

    Re: Dynamically refer to a table in a worksheet index/match function

    It can, but I use it much more than that in some of my workbooks and have yet to see any noticeable overhead. If it doesn't work for you, then you may have to look at a VBA solution (can't help you with that, sorry).

  5. #5
    Registered User
    Join Date
    07-24-2015
    Location
    Toledo, OH
    MS-Off Ver
    Microsoft Office 2010
    Posts
    85

    Re: Dynamically refer to a table in a worksheet index/match function

    Yeah, I love macros and could easily do this with a macro, but I have been specifically told not to use macros for this particular spreadsheet. I will try the INDIRECT and see how it cooperates.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,231

    Re: Dynamically refer to a table in a worksheet index/match function

    Quote Originally Posted by Jerbinator View Post
    Yeah, I love macros and could easily do this with a macro, but I have been specifically told not to use macros for this particular spreadsheet. I will try the INDIRECT and see how it cooperates.
    Ah, yes, so you said. INDIRECT it is, then!

+ 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. Why cant i refer with INDEX and MATCH to a table header
    By esahakos in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-07-2016, 06:21 AM
  2. [SOLVED] index match function using a table and named ranges
    By jugdish in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-23-2015, 03:59 PM
  3. [SOLVED] Index + Match + IF - Function - Wonder why Excel Kept Refer to The Wrong Want
    By cychua in forum Excel Formulas & Functions
    Replies: 25
    Last Post: 06-29-2014, 06:32 AM
  4. multidimensional index and match function to condense table
    By Kamleshsoni in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-14-2013, 04:32 PM
  5. [SOLVED] VBA for creating Index-Match every 2 rows where INDEX refer to a different column per row
    By bisaya789 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-22-2012, 03:46 AM
  6. [SOLVED] Excel 2007 : INDEX MATCH Function from a table
    By mysterio1024 in forum Excel General
    Replies: 1
    Last Post: 03-30-2012, 04:52 PM
  7. Index and match function for same item in the table
    By ronlau123 in forum Excel General
    Replies: 3
    Last Post: 05-15-2011, 02:11 AM

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