0

I have a macro in Excel that filters my table when it is activated by a button.

This is the macro:

Sub Macro2()
'
' Macro2 Macro
'
    ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=2, Criteria1:= _
        Range("D1").Value
End Sub

The macro is filtering the table using the field 2 and the value on D1 cell.

How do I make it use the * wildcard?

For example, if the name is Maria Doe and the cell is Maria it won't show in filter. But if the cell is Maria* it will show in filter.

I think the issue has to do with the criteria:= parameter, but I'm not sure how to set it.

Community
  • 1
  • 1
Lucas Matos
  • 1,112
  • 5
  • 25
  • 42

1 Answers1

0

I have updated your code. this shoud work. check and let me know:

Sub Macro2()
    '
    ' Macro2 Macro
    '

    '
    ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=2, Criteria1:="=" & Range("D2").Value & "*"

End Sub
Jur Pertin
  • 574
  • 4
  • 9