+ Reply to Thread
Results 1 to 4 of 4

Dynamic data validation lists - from multiple select

Hybrid View

  1. #1
    Registered User
    Join Date
    11-29-2022
    Location
    Manchester, England
    MS-Off Ver
    2016
    Posts
    6

    Dynamic data validation lists - from multiple select

    Hi All

    im hoping somebody can help, on getting me started on the below query

    i have a relationship in excel which i want to use to dynamically filter a data validation list based on selection of the parent Collum, i have done this before but this time have added some VBA code which allows a user to select multiple options from the parent drop down




    Please see attached example of data and desired output, for example if a user selects A & B from the parent drop down i want the next column to only filter the related items so in this case 1,2,3



    Any help is greatly appreciated
    Attached Files Attached Files
    Last edited by davidverdon; 11-29-2022 at 05:51 AM.

  2. #2
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,625

    Re: Dynamic data validation lists - from multiple select

    Pl read the yellow banner on the top.
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  3. #3
    Registered User
    Join Date
    11-29-2022
    Location
    Manchester, England
    MS-Off Ver
    2016
    Posts
    6

    Re: Dynamic data validation lists - from multiple select

    Apologies - example workbook now added

  4. #4
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,625

    Re: Dynamic data validation lists - from multiple select

    Code for validation in B column is given in Worksheet event. I have added my code at the end of your code.
    Column A validation is not possible as you have shown. Type manually in A column. I have removed validation for column A.
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim Oldvalue As String
    Dim Newvalue As String
    
    Application.EnableEvents = True
    
    On Error GoTo Exitsub
    
    If Not Intersect(Target, Range("A:A")) Is Nothing Then
      If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
        GoTo Exitsub
      Else: If Target.Value = "" Then GoTo Exitsub Else
        Application.EnableEvents = False
        Newvalue = Target.Value
        Application.Undo
        Oldvalue = Target.Value
          If Oldvalue = "" Then
            Target.Value = Newvalue
          Else
            If InStr(1, Oldvalue, Newvalue) = 0 Then
                Target.Value = Oldvalue & ", " & Newvalue
          Else:
            Target.Value = Oldvalue
          End If
        End If
      End If
    End If
    
    Application.EnableEvents = True
    
    Exitsub:
    
    Application.EnableEvents = True
    
    'Validation for B column
    If Not Intersect(Target, Range("A:A")) Is Nothing And Target.Cells.Count = 1 Then
    Dim S As String
    Dim M, A
    Dim T As Long, Ta As Long
    Application.EnableEvents = False
    
    M = Target.Value
    A = Sheets("Data").Range("A1").CurrentRegion.Offset(1, 0)
    With CreateObject("Scripting.dictionary")
        For Ta = 1 To UBound(A, 1) - 1
        If InStr(1, M, A(Ta, 1)) > 0 Then .Add Ta, A(Ta, 2)
        Next Ta
    N = .items
    M = N(0)
    End With
    
        With Target.Offset(0, 1).Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
            xlBetween, Formula1:=Join(N, ",")
            .IgnoreBlank = True
            .InCellDropdown = True
            .InputTitle = ""
            .ErrorTitle = ""
            .InputMessage = ""
            .ErrorMessage = ""
            .ShowInput = True
            .ShowError = True
        End With
    
    Application.EnableEvents = True
    End If
    
    End Sub
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 11-29-2022 at 10:17 AM.

+ 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. [SOLVED] Using Data Validation to select one of five lists of names.
    By jaljr in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 06-17-2017, 02:20 PM
  2. Dynamic Data Validation Lists
    By DaBrot791 in forum Excel General
    Replies: 12
    Last Post: 08-10-2016, 07:46 PM
  3. Dynamic data validation lists
    By FlashyChap in forum Excel General
    Replies: 2
    Last Post: 01-12-2015, 11:31 AM
  4. Dynamic Data Validation Lists
    By Daniel Brown in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-05-2014, 08:08 AM
  5. Dynamic data validation using multiple lists
    By Danbot007 in forum Excel General
    Replies: 1
    Last Post: 02-01-2011, 08:30 AM
  6. Dynamic Data Validation multiple lists
    By m1066189 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-09-2010, 03:42 PM

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