ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA HELP: Display values in Dropdown2 based on Dropdown2 selection (https://www.excelbanter.com/excel-programming/433604-vba-help-display-values-dropdown2-based-dropdown2-selection.html)

Sam

VBA HELP: Display values in Dropdown2 based on Dropdown2 selection
 
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


Ken Warthen[_2_]

VBA HELP: Display values in Dropdown2 based on Dropdown2 selection
 
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


"sam" wrote:

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


John

VBA HELP: Display values in Dropdown2 based on Dropdown2 selection
 
Sam,
see my follow-up response to your earlier post.
--
jb


"sam" wrote:

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



All times are GMT +1. The time now is 01:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com