|
Public dic As Object
Private Sub ComboBox1_Click()
Me.ComboBox2.Clear
Me.ComboBox3.Clear
Me.ComboBox4.Clear
Me.ComboBox5.Clear
s = Me.ComboBox1.Value
Me.ComboBox2.List = dic(s).keys
End Sub
Private Sub ComboBox2_Click()
Me.ComboBox3.Clear
Me.ComboBox4.Clear
Me.ComboBox5.Clear
s = Me.ComboBox1.Value
s2 = Me.ComboBox2.Value
Me.ComboBox3.List = dic(s)(s2).keys
End Sub
Private Sub ComboBox3_Click()
Me.ComboBox4.Clear
Me.ComboBox5.Clear
s = Me.ComboBox1.Value
s2 = Me.ComboBox2.Value
s3 = Me.ComboBox3.Value
Me.ComboBox4.List = dic(s)(s2)(s3).keys
End Sub
Private Sub ComboBox4_Click()
Me.ComboBox5.Clear
s = Me.ComboBox1.Value
s2 = Me.ComboBox2.Value
s3 = Me.ComboBox3.Value
s4 = Me.ComboBox4.Value
Me.ComboBox5.List = dic(s)(s2)(s3)(s4).keys
End Sub
Private Sub CommandButton1_Click()
ActiveCell = ComboBox1.Value
ActiveCell.Offset(0, 1) = ComboBox2.Value
ActiveCell.Offset(0, 2) = ComboBox3.Value
ActiveCell.Offset(0, 3) = ComboBox4.Value
ActiveCell.Offset(0, 4) = ComboBox5.Value
End Sub
Private Sub CommandButton2_Click()
Unload UserForm1
End Sub
Private Sub UserForm_Initialize()
Dim arr, i, s, s2, s3, s4, s5
With Sheet2
arr = .Range("a3:e" & .Cells(Rows.Count, 1).End(3).Row)
End With
Set dic = CreateObject("scripting.dictionary")
For i = 1 To UBound(arr)
s = arr(i, 1)
If Not dic.exists(s) Then Set dic(s) = CreateObject("scripting.dictionary")
s2 = arr(i, 2)
If Not dic(s).exists(s2) Then Set dic(s)(s2) = CreateObject("scripting.dictionary")
s3 = arr(i, 3)
If Not dic(s)(s2).exists(s3) Then Set dic(s)(s2)(s3) = CreateObject("scripting.dictionary")
s4 = arr(i, 4)
If Not dic(s)(s2)(s3).exists(s4) Then Set dic(s)(s2)(s3)(s4) = CreateObject("scripting.dictionary")
s5 = arr(i, 5)
If Not dic(s)(s2)(s3)(s4).exists(s5) Then Set dic(s)(s2)(s3)(s4)(s5) = CreateObject("scripting.dictionary")
dic(s)(s2)(s3)(s4)(s5) = ""
Next
With UserForm1
.ComboBox1.Clear
.ComboBox1.List = dic.keys
End With
End Sub
|
|