Have a dynamic criteria array in VBA

DRG1978

New Member
Joined
Jan 20, 2017
Messages
37
Hi All,

How should the criteria look for an array that filters all "AMAT2"

See current criteria array with specific AMAT2's:

ActiveSheet.Range("$A$1:$E$1695").AutoFilter Field:=3, Criteria1:=Array( _
"AMAT2-01A", "AMAT2-01B", "AMAT2-01C", "AMAT2-01D", "AMAT2-02A", "AMAT2-02B", _
"AMAT2-02C", "AMAT2-02D", "AMAT2-03A", "AMAT2-03B", "AMAT2-03C", "AMAT2-03D", _
"AMAT2-04A", "AMAT2-04B", "AMAT2-04C", "AMAT2-04D", "AMAT2-05A", "AMAT2-05B", _
"AMAT2-05C", "AMAT2-05D", "AMAT2-06A", "AMAT2-06B", "AMAT2-06C", "AMAT2-06D"),


Thank you all!!:)
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try:
Code:
ActiveSheet.cells(1,1).resize(1695,5).AutoFilter Field:=3, Criteria1:="AMAT2-*"
 
Upvote 0
Beaten 2 it
 
Last edited:
Upvote 0
Thank you very much, JackDanIce!! Much appreciated!!

What would it be if you had two criteria like this:

ActiveSheet.Range("$A$1:$E$1695").AutoFilter Field:=3, Criteria1:=Array( _
"AMAT2-01A", "AMAT2-01B", "AMAT2-01C", "AMAT2-01D", "AMAT2-02A", "AMAT2-02B", _
"AMAT2-02C", "AMAT2-02D", "AMAT2-03A", "AMAT2-03B", "AMAT2-03C", "AMAT2-03D", _
"AMAT2-04A", "AMAT2-04B", "AMAT2-04C", "AMAT2-04D", "AMAT2-05A", "AMAT2-05B", _
"AMAT2-05C", "AMAT2-05D", "AMAT2-06A", "AMAT2-06B", "AMAT2-06C", "AMAT2-06D", _
"AMAT-PLT1", "AMAT-PLT2", "AMAT-PLT3", "AMAT-PLT4", "AMAT-PLT5", "AMAT-PLT6", _
"AMAT-PLT7", "AMAT-PLT8", "AMAT-PLT9")
 
Upvote 0
Hi Fluff,

Do you know what if would be for two criteria? So AMAT2 and AMAT-PLT

See example:

What would it be if you had two criteria like this:

ActiveSheet.Range("$A$1:$E$1695").AutoFilter Field:=3, Criteria1:=Array( _
"AMAT2-01A", "AMAT2-01B", "AMAT2-01C", "AMAT2-01D", "AMAT2-02A", "AMAT2-02B", _
"AMAT2-02C", "AMAT2-02D", "AMAT2-03A", "AMAT2-03B", "AMAT2-03C", "AMAT2-03D", _
"AMAT2-04A", "AMAT2-04B", "AMAT2-04C", "AMAT2-04D", "AMAT2-05A", "AMAT2-05B", _
"AMAT2-05C", "AMAT2-05D", "AMAT2-06A", "AMAT2-06B", "AMAT2-06C", "AMAT2-06D", _
"AMAT-PLT1", "AMAT-PLT2", "AMAT-PLT3", "AMAT-PLT4", "AMAT-PLT5", "AMAT-PLT6", _
"AMAT-PLT7", "AMAT-PLT8", "AMAT-PLT9")
 
Upvote 0
Try:
Rich (BB code):
ActiveSheet.Range("$A$1:$E$1695").AutoFilter Field:=3, Criteria1:=Array("AMAT2*","AMAT-PLT*")
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,099
Members
452,301
Latest member
QualityAssurance

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