Please help with filtering macro

I have a macro which I want to filter items. I need some assistance please.

Currently the macro works, but only when it filters one value. How do I go about having it filter multiple values?

I tried:
 rg.AutoFilter Field:=iCol, Criteria1:="TEST1"&"TEST2"

Open in new window

(but this didnt work).

Full code below:
Sub FilterSpecialType(ws As Worksheet)
'start filter code
Dim rg As Range, rgCopy As Range
With ws
    Set rg = .Range("J1").CurrentRegion
    Set rgCopy = rg.Offset(1, 0).Resize(rg.Rows.Count - 1, rg.Columns.Count)
    iCol = .Range("J:J").Column - rg.Column + 1
    rg.AutoFilter Field:=iCol, Criteria1:="TEST1"
    With Worksheets.Add(After:=Worksheets(Worksheets.Count))       'Destination worksheet
        .Cells(1, 1).PasteSpecial xlPasteValues
        Cells(1, 1).Select
        '.Name = "Filtered from " & ws.Name
        .Name = "Filtered Electronic"
    End With
End With
End Sub

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Have you considered creating a composite field and filtering on that?  For example, if I had a worksheet with FirstName in column A, LastName in column B, and Location in column C, I could create a composite of those values (i.e. value in column A + value in column B + value in column C) and put it in column D, then filter on column D.

A           B             C               D
John      Smith     London    JohnSmithLondon
Bob       Hughes  Delhi        BobHughesDelhi
Ted        Turner   Paris         TedTurnerParis

If you deemed the composite column too unslightly, simply hide the column.

Hope this helps!
eastsidemarketAuthor Commented:
Thanks for your reply.

To be clear, I have many values in this column. I really only want to filter out specific criteria.

So the composite above wouldn't really help.

I'd need to be able to automate just as I would checking off the items once its filtered.

I figure out how to get 1 item to filter in the code, but can't figure out how to get multiple items checked.

please advise!
eastsidemarketAuthor Commented:
i found my own solutions. thanks!

 rg.AutoFilter Field:=iCol, Criteria1:=Array( _
    "item1", "item2", "item3", "item4"), Operator:=xlFilterValues

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
eastsidemarketAuthor Commented:
found my own solution above.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.