|
Private Sub UserForm_Initialize()
Dim ar As Variant, cr As Variant
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("数据")
rs = .Cells(Rows.Count, 2).End(xlUp).Row
ar = .Range("b1:b" & rs)
End With
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
d(Trim(ar(i, 1))) = ""
End If
Next i
Me.ComboBox3.List = d.keys
End Sub
Private Sub ComboBox3_Change()
If Me.ComboBox3 = "" Then Me.ComboBox3.List = Array(""): Exit Sub
Dim arr, i&, d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("数据")
rs = .Cells(Rows.Count, 2).End(xlUp).Row
arr = .Range("b1:c" & rs)
End With
For i = 2 To UBound(arr)
If InStr(arr(i, 1), Me.ComboBox3) Then d(arr(i, 1)) = ""
Next i
Me.ComboBox3.List = d.keys
Me.ComboBox3.DropDown
End Sub
Private Sub ComboBox1_Change()
If Me.ComboBox1 = "" Then Me.ComboBox1.List = Array(""): Exit Sub
Dim arr, i&, d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("数据")
rs = .Cells(Rows.Count, 2).End(xlUp).Row
arr = .Range("b1:c" & rs)
End With
For i = 2 To UBound(arr)
If Trim(arr(i, 1)) = ComboBox3.Text Then
If InStr(arr(i, 2), Me.ComboBox1) Then d(arr(i, 2)) = ""
End If
Next i
Me.ComboBox1.List = d.keys
Me.ComboBox1.DropDown
End Sub
Private Sub ComboBox2_Change()
If Me.ComboBox2 = "" Then Me.ComboBox2.List = Array(""): Exit Sub
Dim arr, i&, d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("数据")
rs = .Cells(Rows.Count, 2).End(xlUp).Row
arr = .Range("b1:d" & rs)
End With
For i = 2 To UBound(arr)
If Trim(arr(i, 1)) = ComboBox3.Text And Trim(arr(i, 2)) = ComboBox1.Text Then
If InStr(arr(i, 3), Me.ComboBox2) Then d(arr(i, 3)) = ""
End If
Next i
Me.ComboBox2.List = d.keys
Me.ComboBox2.DropDown
End Sub
|
|