Hello everyone,
I'm new to VBA. I'm trying to make 3 dependent dropdown lists that depend on each other. I'm using user case to do this, but i'm not sure how to nestle the 3rd dropdown list options. I'm very noob, i don't need this form to be dynamic, i just need to find out how to make combo3 to depend on combo2. ( Please help me with nestled user case / if else logic/ simpler method ?)
My data goes like this:
1>1a>1a1
1>1a>1a2
1>1a>1a3
1>1b>1b1
1>1b>1b2
1>1b>1b3
1>1c>1c1
1>1c>1c2
1>1c>1c3
2> 2a>2a1
and so on ...
__________________________________
Private Sub UserForm_Initialize()
ComboBox1.AddItem "1"
ComboBox1.AddItem "2"
ComboBox1.AddItem "3"
End Sub
___________________________________
Private Sub ComboBox1_Change()
Dim index As Integer
index = ComboBox1.ListIndex
ComboBox2.Clear
Select Case index
Case Is = 0
With ComboBox2
.AddItem "1a"
.AddItem "1b"
.AddItem "1c"
End With
Case Is = 1
With ComboBox2
.AddItem "2a"
.AddItem "2b"
.AddItem "2c"
End With
Case Is = 2
With ComboBox2
.AddItem "3a"
.AddItem "3b"
End With
End Select
End Sub
______________________________
# fails to work from here onwards
Private Sub ComboBox2_Change()
Dim index As Integer
index = ComboBox2.ListIndex
ComboBox3.Clear
Select Case index
Case Is = 1
With ComboBox3
.AddItem "1a1"
.AddItem "1a2"
.AddItem "1a3"
End With
Case Is = 2
With ComboBox3
.AddItem "1b1"
.AddItem "1b2"
.AddItem "1b3"
.AddItem "1b4"
.AddItem "1b5"
.AddItem "1b6"
End With
Case Is = 2
With ComboBox3
.AddItem "1c1"
.AddItem "1c2"
.AddItem "1c3"
End With
Case Is = 3
With ComboBox3
.AddItem "2a1"
.AddItem "2a2"
.AddItem "2a3"
End With
End Select
End Sub
__________________________________________
Bookmarks