|
- Private Sub ComboBox3_Change()
- Dim i As Integer, X As Integer, Y As Integer
- Dim dsD As Object
- ListView1.ListItems.Clear
- With Sheet2
- X = .Range("b65536").End(xlUp).Row
- arrdata = .Range("b2:k" & X)
- End With
- Set dsD = CreateObject("Scripting.Dictionary")
- For i = 1 To UBound(arrdata)
- If ComboBox3.Value = "" Then
- If arrdata(i, 1) Like "*" & ComboBox1.Value And arrdata(i, 2) Like "*" & ComboBox2.Value Then
- dsD(i) = arrdata(i, 4)
- With ListView1.ListItems.Add(, , arrdata(i, 1))
- For Y = 2 To UBound(arrdata, 2)
- .SubItems(Y - 1) = arrdata(i, Y)
- Next Y
- End With
- End If
- Else
- If arrdata(i, 1) Like "*" & ComboBox1.Value And arrdata(i, 2) Like "*" & ComboBox2.Value & "*" And arrdata(i, 4) Like ComboBox3.Value Then
- dsD(i) = arrdata(i, 4)
- With ListView1.ListItems.Add(, , arrdata(i, 1))
- For Y = 2 To UBound(arrdata, 2)
- .SubItems(Y - 1) = arrdata(i, Y)
- Next Y
- End With
- End If
- End If
- Next i
- If dsD.Count > 0 Then ComboBox3.List = WorksheetFunction.Transpose(dsD.items)
- Set dsD = Nothing
- End Sub
复制代码 这三个COMBOBOX的CHANGE事件里几个注释的取消,成上面这样就能达到要求。 |
|