• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Filter Out Multiple Criteria

KathrynJ

New Member
I have a column with multiple values (approx 25) and I want to filter it based on the values I don't want to have visible. Is there a way to "filter out" multiple values? I know how to filter for values I want to see using Array, but I don't know how to do the reverse of that.

This I know:
AutoFilter Field:6, Criteria1:=Array(.... my list), Operator:xlFilterValues

But it doesn't like it if I try:
AutoFilter Field:6, Criteria1:<>Array(.... my list), Operator:xlFilterValues

Any help with this would be most appreciated.
 
A convoluted way:
Code:
Sub blah()
Exclusions = Array("Hello", 10) 'adjust
FieldNo = 6 'adjust
Set AFRng = ActiveSheet.AutoFilter.Range 'presumes a pre-existing autofilter on the active sheet.
Set dict = CreateObject("Scripting.dictionary")
For Each valu In Intersect(AFRng, AFRng.Offset(1)).Columns(FieldNo).Value
  If IsError(Application.Match(valu, Exclusions, 0)) Then dict.Item(valu) = CStr(valu)
Next valu
AFRng.AutoFilter Field:=FieldNo, Criteria1:=dict.items, Operator:=xlFilterValues
End Sub
 
Back
Top