VBA help with code to filter for 3 contains criteria

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
888
Office Version
  1. 365
Platform
  1. Windows
I know when you filter in excel using "contains" it only gives you 2 criterial options. 1st text AND/OR and 2nd text.
Is there a way to do more than 2?
In my case I would like to do 3.
I would like to filter/get all data that contains these 3 words (and they do not have to be together in 1 cell)

"PLATING", "WELD" and "NDT".

I wrote the below formula but it gives me an error 1004 on the 'criteria line for the filter on Field 6

VBA Code:
'Criteria
    ActiveSheet.ListObjects("RT").Range.AutoFilter Field:=6, Criteria1:= _
        "=*PLATING*", Operator:=xlOr, Criteria2:="=*WELD*", Operator:=xlOr, Criteria3:="=*NDT*"
    ActiveSheet.ListObjects("RT").Range.AutoFilter Field:=10, Criteria1:= _
        "Yes"

Range("A1:G" & Cells(Rows.Count, 4).End(xlUp).Row).SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    Sheets("Report").Select
    Range("B2").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False

Help would be greatly appreciated!

Thank you!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
If you cant do it manually then you cant do it with code either. Just do it in a loop and append into the report sheet at each iteration. You should clear the report sheet first or you may run into unintended problems with old data being present.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,252
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top