|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
这三组代码的意思是:通过TextBox5和ComboBox2两个框里输入的条件查找值,在ComboBox3下拉框可以选择,现在问题是,ComboBox2和ComboBox3都支持关键字模糊输入,查找的结果也需要关键字模糊输入才可以,我想让ComboBox3直接显示结果,下拉直接选择就可以了,不用在输入关键字就可以选择,这个代码应该怎么改,老师帮帮忙,谢谢!
Private Sub UserForm_Activate()
Me.TextBox5.Value = Sheets("出库单").Range("B3").Value
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:c" & rs)
End With
For i = 2 To UBound(arr)
If Trim(arr(i, 1)) = TextBox5.Text Then
If InStr(arr(i, 2), Me.ComboBox2) Then d(arr(i, 2)) = ""
End If
Next i
Me.ComboBox2.List = d.keys
Me.ComboBox2.DropDown
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:d" & rs)
End With
For i = 2 To UBound(arr)
If Trim(arr(i, 1)) = TextBox5.Text And Trim(arr(i, 2)) = ComboBox2.Text Then
If InStr(arr(i, 3), Me.ComboBox3) Then d(arr(i, 3)) = ""
End If
Next i
Me.ComboBox3.List = d.keys
Me.ComboBox3.DropDown
End Sub
|
|