+ Reply to Thread
Results 1 to 11 of 11

Formula is valid but not with NAMED RANGE

  1. #1
    Registered User
    Join Date
    07-01-2010
    Location
    Paris, VA
    MS-Off Ver
    Excel 2007
    Posts
    17

    Formula is valid but not with NAMED RANGE

    Been working on this problem for 3 days, cant seem to get it right. I am working off of the general principles for dependent drop-down list from here http://www.contextures.com/xlDataVal15.html

    On the Lists tab, instead of typing in each list, I thought it would be better to create a pivot table for each list that pulls from the ProgramModules Tab. For purposes of this issue, I have a pivot in Lists!B2 with data range 'ProgramModules'!$C$5:$C$400. This works...but I have to manually remove items from the list. I would rather dynamically build the range for the pivot table based upon the header in the Lists Tab for each column.

    Using Column B, with Header as "ACTIVITIES", I am trying to build a dynamic formula that will a unique set of value from everything below ProgramModules!C4 where the adjacent cell in ProgramModules!B:B = Activities. I do this using
    =INDEX(ProgramModules!$B:$B,MATCH(Lists!B$1,ProgramModules!$B:$B,0)):INDEX(ProgramModules!$B:$B,COUNTIF(ProgramModules!$B:$B,Lists!B1))



    The First part (before the colon) should find the first cell reference instance of the Value of Lists!B1 ("Activities") in the B Column of ProgramModules. The second part should find the last cell reference.

    But when I Use this formula for the pivot table range I get an error telling the " Data Source Reference is not valid".


    I feel like I'm 99.9% of the way, but some syntax thing is getting the best of me.


    Can someone please help!

    Attached is the file I am working with.
    Attached Files Attached Files
    Last edited by adventureli; 11-09-2010 at 04:31 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Formula is valid but not with NAMED RANGE

    I like to use KEY columns to give myself unique indexable values that are easy to test. I've added a formula in column D on ProgramModules that indexes the unique values in that data table into the categories in column C.

    With that, we can use a simple INDEX/MATCH on the category name + the row in the list to test if there is a Backpacking-2 or not, and if there is, list the Activity from that row. On the LISTS sheet, the formula in C2 is then copied down and across to J14 to get all the values to appear. You can keep copying for as many new category columns as you add, or as far down as needed to get all the values in any one list to appear.
    Attached Files Attached Files
    _________________
    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
    07-01-2010
    Location
    Paris, VA
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Formula is valid but not with NAMED RANGE

    JB Thanks for the Assistance. I've never created KEYS before, but have always tried to solve by using array comparisons. I always enjoy seeing how others approach problems.

    Although your solution works well, It has created an additional problem for me. For the dependent dynamic dropdowns on the Invoice page, the Blue Section uses a named function ("Uselist" = =INDEX(ValData,1,MATCH(Invoice!B8,Lists!$1:$1,0)):INDEX(ValData,Counter,MATCH(Invoice!B8,Lists!$1:$1,0)) as the Data Validation. The part of this that is now not working correctly is the Second part. which is supposed to determine the total number of values in that list. It is now counting the cells with formulas even if the formula does not produce a visible value.

    You can see the effect of this in the invoice dropdowns. IF you click on the location next to caving, you wont actually see anything in the drop down UNLESS you scroll up. Previously, no blank values were included in the data validation list.

    How do I get it to just return back the range containing visible values?

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Formula is valid but not with NAMED RANGE

    OK, I cry uncle. Here's a macro you can put in the LISTS sheet module that will simply put in the formula, then remove it leaving only flat values an blanks. I offer the macro solution because I see you're already using macros in the workbook. The KEY column on PM page is still used.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-01-2010
    Location
    Paris, VA
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Formula is valid but not with NAMED RANGE

    Thank you! I think the macro was from some sample I was looking at. Nevertheless, I inserted a module in the the sheet List and pasted your code and saved

    Now how to I get it to run?

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Formula is valid but not with NAMED RANGE

    This is a sheet event macro. It does not go in a standard code module (Module1, Module2...) It goes into the SHEET module called List1.

    Doubleclick List1 in the VBAProject panel on the left to open the sheet module. Remove any code from in there you don't actually want.

    Paste in the code I gave you.

    This macro is an "activation" macro so it triggers itself each time you bring up the LISTS sheet onscreen.

  7. #7
    Registered User
    Join Date
    07-01-2010
    Location
    Paris, VA
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Formula is valid but not with NAMED RANGE

    Beautiful!!

    Thank you very much.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Formula is valid but not with NAMED RANGE

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  9. #9
    Registered User
    Join Date
    07-01-2010
    Location
    Paris, VA
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Formula is valid but not with NAMED RANGE

    Thanks! I was wondering how to do that.

  10. #10
    Registered User
    Join Date
    07-01-2010
    Location
    Paris, VA
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Formula is valid but not with NAMED RANGE

    JB,
    Thank you again for your time. It's a simple and elegant solution. Wondering if you'd be willing to help extend the functionality. I'm not a VB programmer, so I have no idea how to replicate the functionality to other Key Columns in the Invoice Tab.

    For example:
    Using your Key formula from column ProgramModules!D , I copied it to ProgramModules!F. I obtained the expected results
    HOwever, when I enter the Shenandoah_River into Lists!L1....Nothing happens (as I would expect given your macro was written for ProgramModules!D.) There may be other columns to add as this is developed. A part of the reason for making everything as dynamic as possible is to reduce maintenance.

    So you better understand where it is all headed,These lists all end up feeding the Invoice sheet dependent drop down lists. Then by an indexed array providing the price in column F on Invoice Sheet. The last piece to solve for the price is to Select the appropriate Group size based upon the value entered in Invoice!b3. In the example of glade_cave, there are 3 group sizes (8 to 16, 17 to 24 and 25 to 32) with the following respective prices (91.04, 71.78, 66.73). I cant figure out how to incorporate the price selection as a function for the user input in Invoice!b3. The current input of 18 should pull the price for the group size of 17 to 24.

    If you're up for it, I'd love some thoughts on this last piece as well.

    Look forward to seeing your solutions.



    I've attached the new file.
    Attached Files Attached Files

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Formula is valid but not with NAMED RANGE

    Dude, this is a never ending project then.

    Why can't you setup your lists and be done with it? All this dynamic range stuff is fine in small controlled doses, but you need these lists up and running and verifiable. If you can add data to your ProgramModules, you can just as readily add them correctly to manually named ranges in the LISTS page.

    Then you can use simple INDIRECT() data validation formulas.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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