VBA HELP: Display values in Dropdown2 based on Dropdown2 selection

  • Thread starter Thread starter sam
  • Start date Start date
S

sam

Hi All!

I want this in VBA that is Excel userform.
Is there a way to display specific values in a "dropdown2" list based on
selecting a value in "Dropdown1" list?

For eg:
Dropdown1 Values: 1,2,3
Dropdown2 Values: 1a,1b,1c,2a,2b,2c,3a,3b,3c

So, If I select "1" in Dropdown1 then I want Dropdown2 to display 1a, 1b, 1c
ONLY
IF I select "2" in Dropdown1 then I want Dropdown2 to display 2a, 2b, 2c ONLY
and so on...

PLEASE HELP!

Thanks in advance
 
Sam,

In the change event of dropdown1 on your userform add the following code.

Private Sub Dropdown1_Change()
Me.Dropdown2.Clear
Select Case Dropdown1
Case 1
Me.Dropdown2.AddItem "1a"
Me.Dropdown2.AddItem "1b"
Me.Dropdown2.AddItem "1c"
Case 2
Me.Dropdown2.AddItem "2a"
Me.Dropdown2.AddItem "2b"
Me.Dropdown2.AddItem "2c"
Case 3
Me.Dropdown2.AddItem "3a"
Me.Dropdown2.AddItem "3b"
Me.Dropdown2.AddItem "3c"
Case Else
'do nothing
End Select
End Sub
 
Back
Top