+ Reply to Thread
Results 1 to 5 of 5

Is there any way to use a dynamic reference inside formula in excel

  1. #1
    Registered User
    Join Date
    05-25-2022
    Location
    Portland, Oregon
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2206 Build 16.0.15321.20000) 64-bit
    Posts
    17

    Is there any way to use a dynamic reference inside formula in excel

    I'm using an xlookup to reference some data and the formula looks like this : =XLOOKUP($F7,QB_Details!$DI$2:$DI$79,QB_Details!$D$2:$D$79,"No Record",0)
    This works fine but I was curious if there is a way to make it more dynamic so these parts: =XLOOKUP($F7,QB_Details!$DI$2:$DI$79,QB_Details!$D$2:$D$79,"No Record",0)
    could be altered to account for many different lookup tables, instead of QB it could be 20 other designations that come before "_Details". The dimensions of all the arrays are identical so no need to alter that part of the lookup.

    I wanted to have it where a user can select that first part that says QB with one of 20 different choices and then have it point to the proper worksheet. Sorry I don't know if I'm being very clear but let's say they select XY from the dropdown, then the lookup would be =XLOOKUP($F7,XY_Details!$DI$2:$DI$79,XY_Details!$D$2:$D$79,"No Record",0) instead.

    I've been looking around for this and haven't seen something that works so far.

    Thanks in advance if anyone knows the answer.

    Rayburn

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

    Re: Is there any way to use a dynamic reference inside formula in excel

    Welcome to the forum.

    If you set up a cell where a user can enter or choose the worksheet they want (e.g. XY in cell A1), then you could do this:

    =XLOOKUP($F7,INDIRECT("'"&A1&"_Details!$DI$2:$DI$79"),INDIRECT("'"&A1&"_Details!$D$2:$D$79"),"No Record",0)
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    05-25-2022
    Location
    Portland, Oregon
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2206 Build 16.0.15321.20000) 64-bit
    Posts
    17

    Re: Is there any way to use a dynamic reference inside formula in excel

    Hi, Thank you for your solution Ali, I had to change it slightly as I was getting #REF error, used =XLOOKUP($F6,INDIRECT(""&A9&"_Details!$DI$2:$DI$79"),INDIRECT(""&A9&"_Details!$D$2:$D$79"),"No Record",0), it didn't like the ' within the double quotes. Works perfectly now though, thanks again for your help.

    Rayburn

  4. #4
    Registered User
    Join Date
    05-25-2022
    Location
    Portland, Oregon
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2206 Build 16.0.15321.20000) 64-bit
    Posts
    17

    Re: Is there any way to use a dynamic reference inside formula in excel

    I think I keep posting this wrong, sorry not my strong suit. But thank you, and I just had to leave out the ' from within the double quotes like this : =XLOOKUP($F6,INDIRECT(""&A9&"_Details!$DI$2:$DI$79"),INDIRECT(""&A9&"_Details!$D$2:$D$79"),"No Record",0) and all is working correctly now, thank you again.

    Rayburn

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Is there any way to use a dynamic reference inside formula in excel

    My suggestion was untested, but glad to have helped.

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

    Thanks for the kind rep comment.

+ 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. Dynamic sheet name reference in excel formula
    By whitebe1 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-28-2022, 03:42 AM
  2. operator with reference name, inside a formula do not work
    By kraka in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-11-2020, 07:09 PM
  3. Using dynamic named ranges from another workbook inside a formula
    By SHUTTEHFACE in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-16-2017, 06:31 AM
  4. Dynamic range inside array formula with use of match
    By konradz in forum Excel General
    Replies: 2
    Last Post: 06-23-2012, 10:54 AM
  5. [SOLVED] external link reference formula inside formula user input
    By jscc in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-20-2012, 04:29 PM
  6. Using a variable inside a worksheet reference in a formula
    By Guinness85 in forum Excel General
    Replies: 1
    Last Post: 07-25-2011, 06:44 PM
  7. Replace reference inside formula
    By malik641 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-20-2005, 11:23 AM

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