VBA复合框,下拉项。要求输入框输入字符串时模糊匹配下拉项字符串并去,除所有不包含输入字符串的下拉
1个回答
展开全部
Dim arr
Private Sub ComboBox1_Change()
ComboBox1.DropDown
a = ComboBox1.Text
For i = ComboBox1.ListCount - 1 To 0 Step -1
If InStr(ComboBox1.List(i), a) = 0 Then
ComboBox1.RemoveItem (i)
End If
Next
If a = "" Then
ComboBox1.Visible = False
ComboBox1.Visible = True
ComboBox1.SetFocus
ComboBox1.DropDown
ComboBox1.Clear
For i = 0 To UBound(arr)
ComboBox1.AddItem arr(i)
Next
End If
End Sub
Private Sub UserForm_Initialize()
arr = Array("abc", "bnb", "hui", "ooo", "pio", "rta", "err", "qwe", "qqq", "wwe")
For i = 0 To UBound(arr)
ComboBox1.AddItem (arr(i))
Next
End Sub
Private Sub ComboBox1_Change()
ComboBox1.DropDown
a = ComboBox1.Text
For i = ComboBox1.ListCount - 1 To 0 Step -1
If InStr(ComboBox1.List(i), a) = 0 Then
ComboBox1.RemoveItem (i)
End If
Next
If a = "" Then
ComboBox1.Visible = False
ComboBox1.Visible = True
ComboBox1.SetFocus
ComboBox1.DropDown
ComboBox1.Clear
For i = 0 To UBound(arr)
ComboBox1.AddItem arr(i)
Next
End If
End Sub
Private Sub UserForm_Initialize()
arr = Array("abc", "bnb", "hui", "ooo", "pio", "rta", "err", "qwe", "qqq", "wwe")
For i = 0 To UBound(arr)
ComboBox1.AddItem (arr(i))
Next
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |