+ Reply to Thread
Results 1 to 8 of 8

Dynamic Name Range not working with indirect formula

  1. #1
    Registered User
    Join Date
    02-14-2017
    Location
    Hosle, Norway
    MS-Off Ver
    2013, 365, 2016
    Posts
    35

    Dynamic Name Range not working with indirect formula

    Hi,

    I am trying to figure out if it is possible to use a dynamic name range in an indirect formula, I can't get it to work. I think the terms I use to explain might not be the correct terms, so I'll try to explain as detailed as I can, and I'll add an example to illustrate my question.

    A named range can be defined by selecting the table with data. For instance a list of customer numbers and names, then giving it a name in the white box in the upper left corner and pressing enter. In my example, I selected A1:B7 and named it StaticNameRange

    However, I want it to be more dynamic, so that it selects all cells, even if I add more customers later. I know I can use A:B, but that has it's limitations, and I want to learn more about named ranges. So I use a formula to define the range:

    =Offset($A$1,0,0,COUNTA(A:A),2)

    This works fine for ordinary formulas. I posted in my example that I use a VLOOKUP on the named range to search for a customer number and return the name and it returned the results fine. But When I put the name of the range in H2, and use Indirect(H2) instead of the name of the range, it returns #REF.

    When defining the name of the range in the first way I mentioned, it works fine to use Indirect, this is only a problem when using the offset formula to define the range.

    So my question is: How can I use an dynamic Name range in an indirect formula? Maybe there is another way to make a dynamic name range that will work?

    Best Regards
    Tbez
    Attached Files Attached Files

  2. #2
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Dynamic Name Range not working with indirect formula

    INDIRECT "does not like" dinamic named ranges

  3. #3
    Registered User
    Join Date
    02-14-2017
    Location
    Hosle, Norway
    MS-Off Ver
    2013, 365, 2016
    Posts
    35

    Re: Dynamic Name Range not working with indirect formula

    I hear you tim201110.

    Indirect can be quite picky when it comes to what it likes and doesn't like. I found out the other day that i doesnt like ()-signs in sheet names either..

    Maybe it is best to just use =A1&"B:"&COUNTA(A:A) to keep indirect happy

  4. #4
    Registered User
    Join Date
    02-14-2017
    Location
    Hosle, Norway
    MS-Off Ver
    2013, 365, 2016
    Posts
    35

    Re: Dynamic Name Range not working with indirect formula

    Does anyone have a suggestion for a dynamic name range that will work with indirect?

  5. #5
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Dynamic Name Range not working with indirect formula

    Tbez,

    INDIRECT will not work with dynamic named ranges, you can use same condition to get for range instead. Can you please explain what are you trying to achieve in your original file?
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  6. #6
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

  7. #7
    Registered User
    Join Date
    02-14-2017
    Location
    Hosle, Norway
    MS-Off Ver
    2013, 365, 2016
    Posts
    35

    Re: Dynamic Name Range not working with indirect formula

    Hi,

    Thank you for helping Tim and Haseeb. Indirect didnt work with dynamic name ranges, but with the help of a short VBA, it worked afterall.

    Tim posted a link to a post by SirJB7, and I'll explain how it worked in this post.
    I inserted the VBA-code below in a new module.

    Please Login or Register  to view this content.
    The code adds a function called RetrieveRangeForName

    So from my original formula, I added the new function:

    Before: =VLOOKUP(I2,INDIRECT(H2),2,False)
    After: =VLOOKUP(I2,INDIRECT(RetrieveRangeForName(H2)),2,FALSE)

    And voila, dynamically named ranges work with indirect!

    Best regards Tbez.

    PS: My attachement is a macro. if you want to test this withoout downloading a macro, you can use the first attachement I posted, and paste the code to try the same with no risk.

  8. #8
    Registered User
    Join Date
    10-09-2013
    Location
    Burley in Wharfedale, England
    MS-Off Ver
    Excel 365
    Posts
    1

    Thumbs up Re: Dynamic Name Range not working with indirect formula

    Hi there,

    I had a weird situation where an example spreadsheet that I downloaded from the web to show how to use a dynamic named range drop-down worked 100% fine but when I tried to do it on my spreadsheet, it just refused with the message that it evaluates to an error!

    My spreadsheet had a sheet called "Personal Finance" and "Business Finance". In my table, I had a field called category with a drop down for either "Personal" or "Business". When I chose one of these, I wanted the next field to have a drop down that was specific to either personal or business finance items.

    My solution was to write in the dependent data validation field the following formula:
    =INDIRECT("'" & A2 & " Finance'!$A$2:$A$20"). So this had the effect of giving me a dynamic drop down list in column B that was dependant on the value in column A.

    Interestingly, if I only have say 4 values in my Personal Finance list, and my range says A2:A20, it only shows the 4 values so Excel has the intelligence to filter out the blank values. I could have used a counta function I suppose but that makes the formula long and clunky and this worked so no need.

+ 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. Using INDIRECT formula to reference a dynamic range on another sheet
    By Travisty in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-01-2018, 12:22 PM
  2. Indirect Formula not working with Named Range
    By SHUTTEHFACE in forum Excel General
    Replies: 2
    Last Post: 10-03-2014, 02:15 PM
  3. Sum + Indirect using Dynamic Range
    By shocks24 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2014, 04:19 PM
  4. INDIRECT function not working inside MATCH with dynamic ranges
    By fotografer in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-26-2014, 02:09 AM
  5. Replies: 15
    Last Post: 09-10-2013, 05:31 AM
  6. [SOLVED] Indirect Validation after using SUBSTITUTE on a Dynamic Name Range NOT WORKING
    By Jason Eric in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-03-2013, 04:26 AM
  7. Indirect and Dynamic Range
    By Graham Haughs in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 08-03-2006, 03:40 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