Creating a filter macro and an OR filter macro

mille238

New Member
Joined
Jan 7, 2011
Messages
1
Hi all,

I'm trying to create a filter macro that will select a specific column from a given worksheet and filter on a given variable.

I'm also trying to do the same thing with an OR operator. Ex: I need to filter: equals THIS OR equals THAT.

I want to try and keep them general so that I can reuse this macro. I want to be able to pass in what worksheet to perform the macro on, what column and what to filter on.

Any help would be greatly appreciated.

Thanks
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Welcome to the Forum,

Take a look at this and see if you can adapt it. If not then please give specific information like column number and criteria.

Sub mcrFilter()
'
' mcrFilter Macro
'
'
Range("A1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$D$8").AutoFilter Field:=4, Criteria1:="=29", _
Operator:=xlOr, Criteria2:="=35"
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,087
Messages
6,128,740
Members
449,466
Latest member
Peter Juhnke

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