VBA help with code to filter for 3 contains criteria

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
681
Office Version
  1. 2019
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!
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
8,323
Office Version
  1. 365
Platform
  1. Windows
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,423
Messages
5,601,574
Members
414,460
Latest member
uctc

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
Top