【发布时间】:2015-02-20 04:18:29
【问题描述】:
我想根据第一个组合框填充第二个组合框。
第一个组合框具有以下值: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
例如当我在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
【问题讨论】: