Autofilter with multiple criteria Array and wild card

blbat

Active Member
Joined
Mar 24, 2010
Messages
338
Office Version
  1. 2016
  2. 2013
this snippet of code is fully functional within the Sub. ("lr" is already dimmed and returns LastRow)
Code:
'   Hide all rows not equal to "NoGood"
    Columns("H:H").AutoFilter
    ActiveSheet.Range("$H$1:$H$" & lr).AutoFilter Field:=1, Criteria1:="<>" & "NoGood"

now i need to do the same type of Autofilter on a different column with three possible criteria, and each of the criteria must end with a wildcard because the last character can be different.

so, I need to:

' Hide all rows not equal to "SEE*" OR "DEE*" OR "MMM*" (where the "*" is wildcard)

here's what I have tried:
(the rest of the code to make this functional already works)

Code:
Dim MyArray as Variant

MyArray = Array("SEE*", "DEE*", "MMM*")

    Columns("D:D").AutoFilter
'The following line is INCORRECT, but shows what I am attempting to do:

 ActiveSheet.Range("$D$1:$D$" & lr).AutoFilter Field:=1, Criteria1:=Array("<>" & MyArray)

I Need to know how to get that "not equal to" working with an Array, and if using wildcards inside an Array like this will work.

any help would be appreciated.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Dang. i should have done a better "search" for this answer...looks like this question has been asked many times. maybe a loop instead.
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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