Reputation: 139
I am trying to filter a Data Table with VBA but I didn't manage to
If I write the Following ... It filters perfectly.
ActiveSheet.ListObjects("OPT").Range.AutoFilter Field:=17, Criteria1 _
:="=QQQ", Operator:=xlAnd
Now if in the Cell C2
I enter the value QQQ
ActiveSheet.ListObjects("OPT").Range.AutoFilter Field:=17, Criteria1 _
:="=" & Range("C2"), Operator:=xlAnd
Excel filters and gives no results... I tried using Range("C2").Value
and Range("C2").Text
but have same issue... no result in the filtering ... Does anyone have an idea of where my syntax is wrong... Thanks
Upvotes: 0
Views: 116
Reputation: 278
I tried this out on Excel 2010, and you can simply reference the Range of the value to use and it will filter. So for your example ActiveSheet.ListObjects("OPT").Range.AutoFilter Field:=17, Criteria1:=Range("C2"), Operator:=xlAnd
will work and filter the list.
Upvotes: 1