Autofilter with multiple conditions (VBA)

David2

New Member
Joined
Jan 13, 2018
Messages
39
I'd like to sort my data (A1:D10 with headers) by values in column B.


I want to only show entries that do not contain 123 or ABC or 456 or DEF in column B (entries can be at the start, middle or end therefore I'm guessing I'd need to use * wildcards).


Autofilter seems to limited to two conditions so I'm wonder how do I fit four OR conditions here? Array perhaps?

Thank you.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi there.

If you can add an additional column (E?), put this formula in it =SUMPRODUCT(COUNTIF(B2,{"*123*";"*ABC*";"*456*";"*DEF*"}))>0 then drag down and filter that column for FALSE. What id does is count how many matches occur in B2 for any of the searches. If any are found the count is greater than 0 and evaluates to TRUE. If you cant add an additional column, it is still possible to achieve, but you will need to use VBA (I can help if thats the case).
John
 
Upvote 0
Cross posted https://www.excelforum.com/excel-pr...filter-macro-with-multiple-or-conditions.html

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
I apologize Fluff.

Hi there.

If you can add an additional column (E?), put this formula in it =SUMPRODUCT(COUNTIF(B2,{"*123*";"*ABC*";"*456*";"*DEF*"}))>0 then drag down and filter that column for FALSE. What id does is count how many matches occur in B2 for any of the searches. If any are found the count is greater than 0 and evaluates to TRUE. If you cant add an additional column, it is still possible to achieve, but you will need to use VBA (I can help if thats the case).
John



jmacleary , that's a very elegant solution! Can I use it to filter A1:B2 entries on Sheet1, while having the True/False helper column positioned on Sheet2?

I've modified the formula on Sheet2 to check Sheet1 data and assign T/F values =SUMPRODUCT(COUNTIF(Sheet1!B2,{"*123*";"*ABC*";"*456*";"*DEF*"}))>0

However I don't know how to use that to create AutoFilter for Sheet1.
 
Upvote 0
Hello again. No the filter would have to be on a column in the filtered data, i.e. on sheet1.
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,224
Members
452,620
Latest member
dsubash

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