Simple Filter (and Cancel Filter)

rob1987

New Member
Joined
Feb 14, 2011
Messages
39
Hello,

I think this should be a really easy code but I'm really not sure how to do it.

Basically, I want to set up a Macro in an worksheet called "input" that filters all rows based on the cell value in column C being greater than or equal to 0.

I'm going to set up a command button to do this rather than having to go through the process of filtering each time.

This leads me onto the second part, is there a seperate code to remove the filter?

Many Thanks,
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Code for first part:
Code:
Sub MyFilter ()
With Sheets("Input")
    .Select
    .Range("C1").CurrentRegion.AutoFilter Field:=3, Criteria1:=">=0", Operator:=xlAnd
End With
End Sub
Code for second part:
Code:
Sub RemoveFilter ()
With Sheets("Input")
    If .AutoFilterMode Then .AutofilterMode = False
End With
End Sub
 
Upvote 0
Thanks Jack.

I worked out I could also just Record Macro, set the filter, and stop recording. And then the same for clearing it.
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

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