我写了一个宏来搜索过滤器中A列中的完全匹配,它需要在B列中进行搜索的近似匹配。现在我只将它作为完全匹配,我需要帮助使它成为一个近似匹配代码。以下是我的代码:
Sub SearchBox1()
Dim myButton As OptionButton
Dim MyVal As Long
Dim sht As Worksheet
Dim myField As Long
Dim DataRange As Range
Dim mySearch As Variant
'Load Sheet into A Variable
Set sht = ActiveSheet
'Unfilter Data (if necessary)
On Error Resume Next
sht.ShowAllData
On Error GoTo 0
'Filtered Data Range (include column heading cells)
ActiveSheet.Range("$A50:$L$130").AutoFilter Field:=2, Criteria1:=sht.Shapes("CountrySearch").TextFrame.Characters.Text
Exit Sub
End Sub
感谢您的帮助!
答案 0 :(得分:1)
尝试将Criteria1更改为此
如果它正在搜索字符串:
Criteria1:= “*”& sht.Shapes(“CountrySearch”)。TextFrame.Characters.Text & “*”强>
或者,如果你有数字
标准1:= “> =”& sht.Shapes( “CountrySearch”)。TextFrame.Characters.Text