Consulting

Results 1 to 6 of 6

Thread: Creating Dynamic Named Ranges for Dependent Data Validation Lists

  1. #1
    VBAX Regular
    Joined
    Aug 2012
    Posts
    24
    Location

    Creating Dynamic Named Ranges for Dependent Data Validation Lists

    Hello All,

    I am trying to create macro that can dynamically name and update named ranges that are being used in dependent data validation lists on a different page. Thus far, I have only been able to dynamically create the level of the data validation, and keep getting an error message when I attempt to select the dependent variable.

    I have attached the following workbook to give you a better idea of what I am trying to do.

    Thank you,

    Zac

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    You only need 1 little line of VBA
    Attached Files Attached Files

  3. #3
    VBAX Regular
    Joined
    Aug 2012
    Posts
    24
    Location
    Thank you for the reply. I keep getting an error though.

  4. #4
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    What is the error message? Unless you tell us we could well spend all next week guessing.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  5. #5
    VBAX Regular
    Joined
    Aug 2012
    Posts
    24
    Location
    I apologize...it's working correctly now. Thank you!

  6. #6
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    You don't need VBA. Neither do you need all those named ranges.
    Select Data Validation! D2 and then define these names.

    Name:colNum RefersTo: =MATCH('Data Validation'!$B2,Data!$1:$1,0)
    Name:columnOfInterest RefersTo: =OFFSET(Data!$A:$A,0,colNum-1)
    Name:Style RefersTo: =Data!$A$2:INDEX(Data!$A:$A,MATCH("zzzz",Data!$A:$A),1)
    Name:ValidationList RefersTo: =INDEX(columnOfInterest,2,1):INDEX(columnOfInterest,MATCH("zzzz",columnOfIn terest),1)

    Then, leave the validation on Column B as is (i.e. list validation source =Style)
    and change the validation on each cell of column C to List Validation with the source =ValidationList
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •