Auto filter with multiple wildcards

前端 未结 2 2026
情书的邮戳
情书的邮戳 2021-01-24 07:49

Is there a way to use an Excel auto filter, whereby you set a predefined list of values to filter by, and it will return all the cells in a column that contain that phrase? For

相关标签:
2条回答
  • 2021-01-24 08:19

    The second method doesn't work because if you are using wildcards in an array to autofilter you are limited to only 2 terms. There are workarounds and solutions on the web.

    0 讨论(0)
  • 2021-01-24 08:31

    You cannot filter more than two criteria with wildcards. The nature of your sample data is such that you would be using ="Brian*", ="Mark*" or ="*John" to wildcard the first names as either Begins with... or Ends with... criteria. You can only use two of these in any one filter operation. You cannot add a third by creating an array of wildcarded values.

    This works:

    with activesheet.cells(1, 1).currentregion
        .AutoFilter Field:=1, Criteria1:="=Brian*", Operator:=xlOr, Criteria2:="=*John"
    end with
    

    This does not work:

    with activesheet.cells(1, 1).currentregion
        .AutoFilter Field:=1, Criteria1:=Array("Brian*", "Mark*", "*John"), Operator:=xlFilterValues
    end with
    
    0 讨论(0)
提交回复
热议问题