Dependent Drop Downs

RaviWildcat

Board Regular
Joined
Jun 18, 2010
Messages
119
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi - this should be a very easy task but I've been spinning my wheels for 30 minutes so I'm posting on mrexcel.

I'm creating a sign in sheet. On another tab I have a list of names

Last_Name First_Name
Brady Greg
Brady Marsha
Cunningham Richard
Cunningham Joanie

On my sign in sheet I want to pull up last names, and then I want to pull up valid first names based on the last name.

So, under the last name, I want a dropdown that lets me choose Brady or Cunningham.

If I select Brady

under the first name I want a dropdown that lets me choose either Greg or Marsha

I can get the first drop down ok. I'm struggling with the dependent drop down based upon the first value.

(I tried creating a name called Brady and then using indirect for the first name but that hasn't worked sadly)
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi RaviWildcat
If your list of names started from cell("A1") in list named "another tab"
try this
whrere Private Sub Worksheet_Change(ByVal Target As Range)- event for your sign sheet and last name drop down cell is "F1"
The first name dropdown will generate in "G1"

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Set nms = CreateObject("System.Collections.ArrayList")
    If Not Intersect(Target, Range("F1")) Is Nothing Then
        nms.Clear
        With Worksheets("another tab")
            lur = .Cells(Rows.Count, 1).End(xlUp).Row
            For i = 2 To lur
                If .Cells(i, 1).Value = [f1].Value Then
                    If Not nms.Contains(.Cells(i, 2)) Then .Add .Cells(i, 2)
                End If
            Next
        End With
        nms.Sort
        first_names = Join(nms.toarray, ",")
        With [G1].Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=first_names
        End With
    End If
End Sub
 
Upvote 0
With 365, I would just use the inbuilt functions to achieve this without the need for VBA. Note the formulas in D2 & E2, and the validation lists in G2 & H2.
Book1
ABCDEFGH
1Last NameFirst NameLast UniqueFirst UniqueLast Name ChoiceFirst Name Choice
2BradyGregBradyGregBradyGreg
3BradyMarshaCunninghamMarsha
4CunninghamRichie
5CunninghamJoanie
Sheet1
Cell Formulas
RangeFormula
D2:D3D2=UNIQUE(A2:A5)
E2:E3E2=FILTER(B2:B5,A2:A5=G2,"")
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
G2List=$D$2#
H2List=$E$2#


Book1
ABCDEFGH
1Last NameFirst NameLast UniqueFirst UniqueLast Name ChoiceFirst Name Choice
2BradyGregBradyRichieCunninghamJoanie
3BradyMarshaCunninghamJoanie
4CunninghamRichie
5CunninghamJoanie
6
Sheet1
Cell Formulas
RangeFormula
D2:D3D2=UNIQUE(A2:A5)
E2:E3E2=FILTER(B2:B5,A2:A5=G2,"")
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
G2List=$D$2#
H2List=$E$2#
 
Upvote 0
With 365, I would just use the inbuilt functions to achieve this without the need for VBA. Note the formulas in D2 & E2, and the validation lists in G2 & H2.
Book1
ABCDEFGH
1Last NameFirst NameLast UniqueFirst UniqueLast Name ChoiceFirst Name Choice
2BradyGregBradyGregBradyGreg
3BradyMarshaCunninghamMarsha
4CunninghamRichie
5CunninghamJoanie
Sheet1
Cell Formulas
RangeFormula
D2:D3D2=UNIQUE(A2:A5)
E2:E3E2=FILTER(B2:B5,A2:A5=G2,"")
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
G2List=$D$2#
H2List=$E$2#


Book1
ABCDEFGH
1Last NameFirst NameLast UniqueFirst UniqueLast Name ChoiceFirst Name Choice
2BradyGregBradyRichieCunninghamJoanie
3BradyMarshaCunninghamJoanie
4CunninghamRichie
5CunninghamJoanie
6
Sheet1
Cell Formulas
RangeFormula
D2:D3D2=UNIQUE(A2:A5)
E2:E3E2=FILTER(B2:B5,A2:A5=G2,"")
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
G2List=$D$2#
H2List=$E$2#

What an elegant approach! Thank you!
 
Upvote 0

Forum statistics

Threads
1,215,098
Messages
6,123,082
Members
449,094
Latest member
mystic19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top