写了一个macrossearch,需要大致的匹配,而不是确切的

我写了一个macros来search列A中的精确匹配的filter,并且它需要在列B中search的近似匹配。现在,我只将它作为完全匹配,并且我需要帮助使其成为近似匹配代码。 以下是我的代码:

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 

感谢您的帮助!

尝试将Criteria1更改为此

如果它正在search一个string:

Criteria1:= “*”& sht.Shapes(“CountrySearch”).TextFrame.Characters.Text &“*”

或者,如果你有号码

Criteria1:= “> =” &sht.Shapes(“CountrySearch”)。TextFrame.Characters.Text