+ Reply to Thread
Results 1 to 10 of 10

Update a validation list based on value of another cell

  1. #1
    Registered User
    Join Date
    03-05-2009
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2003
    Posts
    4

    Update a validation list based on value of another cell

    I've attached sample dummy data to illustrate what I'm trying to do.

    In sheet 1, there are two columns, Category and Subgroup. The cell validation for Category is pulled from the category list on sheet 2. Basically, what I want to happen is depending on what is selected as the category, only the related sub-groups would be populated in the sub-group validation dropdown list. In other words, if Fruit is selected as the category, I only want Apple, Orange, Pear, Banana, etc to be in the validation drop down list for the sub group. If vegetable, then only Corn, Green Bean, Cucumber, and Peas should be shown.

    I've included two options for the relationship list as I'm not tied to either style and not sure which would be easier to work with.

    I've tried going down a couple of different paths but keep getting caught at a dead end.

    Thanks for your help with this in advanced. I appreciate it.
    Attached Files Attached Files
    Last edited by JDM11808; 03-09-2009 at 02:01 PM.

  2. #2
    Forum Contributor GuruWannaB's Avatar
    Join Date
    01-24-2008
    Location
    An hour due East of Cowtown Ohio
    MS-Off Ver
    2010
    Posts
    421

    Re: Update a validation list based on value of another cell

    Take a look at this...I've had this in my files for dependent validation boxes....this shows an example of what you want to do....also has code for if you want the secondary validations to clear if there is a change to the primary.
    Attached Files Attached Files
    Last edited by GuruWannaB; 03-05-2009 at 03:30 PM.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Update a validation list based on value of another cell

    Hello GuruWannab,

    When posting answers you should include some explanation of the solution along with any pertinent code. There are occasions were the amount of code prohibits posting it all or providing an in depth explanation of it. That is definitely not the case here. The forum is a place to share information and learn from others. Please amend your post to include more details.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Contributor GuruWannaB's Avatar
    Join Date
    01-24-2008
    Location
    An hour due East of Cowtown Ohio
    MS-Off Ver
    2010
    Posts
    421

    Re: Update a validation list based on value of another cell

    My apologies...I thought the documentation in the file was enough...but sometimes you get to a point where you can look at something and absorb how it works and you don't realize that others can't. Ohhhh I feel like Sylar on Heroes!....lol

    In anycase...in the spreadsheet I attached...the dependent validations rely on named ranges...each having a respective relationship with items in other ranges.

    For example, if you highlight A2:a5 - you will see that is a named range "animals". Your validation list can be set for the named range instead of a range of cells and their values. If you highlight B2:b5 - the named range is "Canine". Using named ranges...you can have one validation set to select what type of animal...then the second validation is =indirect(the first validation cell) and it will then seek out that range name and use the range as the available selectables.

    In the sheet...there are two examples of dependent validations..the top one you will notice that if you change the CLASSES...the other two automatically blank out....per the description on the sheet...you can right click on the tab and select VIEW CODE...there is a vba code built that anytime there is a change to a more dominent validation cell...the subordinates clear out. This does not happen to the second set of validations on row 17 as the code is designed only to look at the row 4 validations in I and J columns

    Hope that helps
    Last edited by GuruWannaB; 03-05-2009 at 04:14 PM.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Update a validation list based on value of another cell

    Hello GuruWannaB,

    Thank you for adding the write up.

  6. #6
    Registered User
    Join Date
    03-05-2009
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Update a validation list based on value of another cell

    That's very helpful, i didnt catch the indirect was referencing the named field instead of a value.

    As for the code, any suggestion on how to have it run for a series of selections (i.e. have a series of these selection lists in all of column H, I & J, not just a single hard coded location, and if any of those items get changed have it do the clear out for that specific row)

    Let me know if that doesnt make sense.

    Thanks for your help, I really appreciate it

  7. #7
    Forum Contributor GuruWannaB's Avatar
    Join Date
    01-24-2008
    Location
    An hour due East of Cowtown Ohio
    MS-Off Ver
    2010
    Posts
    421

    Re: Update a validation list based on value of another cell

    You can modify the code where a specific cell reference is...and make it a column reference.

    For example. In the first IF/NOT

    Please Login or Register  to view this content.
    you could change the ("H4") to ("H:H") - that would then make it that ANY change to ANY validation in the H Column will cause the validations in I4 and J4 to clear...
    I help because of the Pavlovian dog that resides in the inner me...so if you are happy with the results, please add to my reputation. It helps keep me motivated!



    Please mark your threads as Solved once it is solved. Check the FAQ's to see how.

  8. #8
    Registered User
    Join Date
    03-05-2009
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Update a validation list based on value of another cell

    Thanks again for your help. However, I don't think i was clear what i was looking for with the last part. I'm looking more for a break in the code so that for example, if H7 were to change it would clear out I7 and J7, if K8, it would clear out I8, K8. Basically, how would you go about having it do the clear method without hardcoding the cells to be cleared. Does that make sense?

    Thanks again for your help.

  9. #9
    Forum Contributor GuruWannaB's Avatar
    Join Date
    01-24-2008
    Location
    An hour due East of Cowtown Ohio
    MS-Off Ver
    2010
    Posts
    421

    Re: Update a validation list based on value of another cell

    How many validations are you going to have? You would ideally, I would think have only 1 primary and 1 secondary and so on...

    What would the purpose be to have 2 primary validations? Maybe I'm not sure what you mean...but to do it...select the respectively dependent validations and name them as a range. Then instead of the hardcoding to a particular cell..you have it hardcoded to a range that can then clear multiple cell validations.

  10. #10
    Registered User
    Join Date
    03-05-2009
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2003
    Posts
    4

    Thumbs up Re: Update a validation list based on value of another cell

    Sorry for the confusion once again. It's that I have a long list of items and each of these items has a couple of fields with this validation. What I was hoping for is that if on a particular item, one of the validations is changed, it would clear out the subsequent validations for that single item. (i've attached a jpg of a sample table)

    If I were to change Bob Jones to Feline, i'd want Poodle and French to clear. However, if i change Billy Bob from pigeon to eagle, i'd want rat with wings to clear. And preferebly, since i'm dealing with around 2000 of these entries, hard coding each cell isnt really an option. I understand what you're saying with the range, but when i tried, it cleard out the secondary and/or Tertiary dependent for all items in the list.

    Does that make more sense?

    I really appreciate your follow-up with this.

    Thanks!
    Attached Images Attached Images

+ 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