VB Multiple AutoFilter Array question?

MichaelRSnow

Active Member
Joined
Aug 3, 2010
Messages
409
If have this vb that appplies an auto filter array, is it possible to layer multiple if statements over the top to increase/change the amount of arrays being used in the filter


Code:
If Workbooks(Range("B4").Value).Sheets("Sheet1").Range("I12") = "1" Then
    With Workbooks(Range("B6").Value).Sheets("Sheet2").Rows("1:1")
        .AutoFilter Field:=25, Criteria1:=Array("=*First*", "=*Second*"), Operator:=xlFilterValues
    End With
Else
End If

i.e.
If Range("I12") = "1" Then Array includes ("=*First*", "=*Second*") or
If Range("J12") = "1" Then Array includes ("=*Thrid*", "=*Fourth*") or
If Range("I12") = "1" and Range("J12") = "1"Then Array includes ("=*First*", "=*Second*","=*Thrid*", "=*Fourth*")

So the Array changes depending on the IF statement?

Any help would be much appreciated
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
There have been no responses so far so i assume this is not possible to do, trying to avoid creating lists elsewhere and instead nest the possible options within the vba logic itself.

The other possible method which also seems impossible would be to run the IF statement and apply the filter, then run the next IF statement and then add to the existing filter, which doesn't feel possible from the threads i have seen.
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,816
Members
449,095
Latest member
m_smith_solihull

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