改变F5单元内容后,点按钮。
Dim d2, d3, l3
Private Sub ComboBox1_Change()
[e5] = d2(ComboBox1.Value)
End Sub
Private Sub CommandButton1_Click()
Application.EnableEvents = False
Dim arr, i&, m&
arr = [a22:b32]
Set d2 = CreateObject("Scripting.Dictionary")
Set d3 = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(arr)
If Not d2.exists(arr(i, 1)) Then
d2(arr(i, 1)) = arr(i, 2)
m = m + 1
d3(arr(i, 2)) = m
End If
Next
ComboBox1.List() = d2.keys
l3 = Sheet1.Range("F5")
ComboBox1.ListIndex = d3(l3) - 1
Application.EnableEvents = True
End Sub