|
Public d As Object
Public ListArr1
Private Sub ComboBox1_Change()
Dim i As Long
Dim d0 As Object
Set d0 = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(ListArr1)
If ListArr1(i, 1) = ComboBox1.Text Then d0(ListArr1(i, 2)) = ""
Next
TextBox1.Text = ""
ComboBox2.Text = ""
ComboBox2.List = d0.Keys()
End Sub
Private Sub ComboBox2_Change()
Dim i As Long
For i = 1 To UBound(ListArr1)
If ListArr1(i, 1) = ComboBox1.Text And ListArr1(i, 2) = ComboBox2.Text Then TextBox1.Text = ListArr1(i, 3): Exit For
Next
End Sub
Private Sub UserForm_Initialize()
Dim i As Long
Dim Sh As Worksheet
Set d = CreateObject("Scripting.Dictionary")
Set Sh = ThisWorkbook.Sheets("数据")
Sr = 2
Sc = 1
Er = Sh.Cells(Sh.Rows.Count, Sc).End(3).Row
Ec = 3
ListArr1 = Sh.Range(Sh.Cells(Sr, Sc), Sh.Cells(Er, Ec))
For i = 1 To UBound(ListArr1)
d(ListArr1(i, 1)) = ""
Next
ComboBox1.List = d.Keys()
End Sub
|
评分
-
1
查看全部评分
-
|