作者:烟为你吸_811 | 来源:互联网 | 2023-05-18 16:32
Iwanttofillthesecondcomboboxbasedonthefirstcombobox.Thefirstcomboboxhavetheseval
I want to fill the second combo box based on the first combo box.
The first combo box have these values: John, Marry, Lona, Fred
我想基于第一个组合框填充第二个组合框。第一个组合框有这些值:John,Marry,Lona,Fred
A B
1 John 384
2 John 475
3 John 450
4 Marry 616
5 Marry 526
6 Lona 569
7 Lona 234
8 Lona 937
9 Lona 477
10 Fred 286
For example when I choose John in combobox1, there should be these values in combobox2: 384,475,450
My code doesn't work:
例如,当我在combobox1中选择John时,在combobox2中应该有这些值:384,475,450我的代码不起作用:
Private Sub ComboBox1_change()
Set rngItems = Sheet1.Range("B1:B10")
Set oDictiOnary= CreateObject("Scripting.Dictionary")
With Sheet2.ComboBox2
For Each cel In rngItems
If ComboBox1.Value = cel.Value Then
oDictionary.Add cel.Value, 0
.AddItem cel.Value
End If
Next cel
End With
End Sub
2 个解决方案