Clear filters macro not working

imatomic

New Member
Joined
Jan 28, 2008
Messages
31
I recorded these filter events and they are stored in one module. It malfunctions on "ActiveSheet.ShowAllData". Funny thing is as I tested them they worked until I got to the fifth macro. Now none will run?? I'm perplexed.

End goal was to tie these to data valadation selections.

Code:
Sub Clear_Filter()
    ActiveSheet.ShowAllData
End Sub

Sub One()
    ActiveSheet.ShowAllData
    ActiveSheet.Range("$A$8:$Q$200").AutoFilter Field:=3, Criteria1:="1"
End Sub

Sub Two()
    ActiveSheet.ShowAllData
    ActiveSheet.Range("$A$8:$Q$200").AutoFilter Field:=3, Criteria1:="2"
End Sub

Sub Three()
    ActiveSheet.ShowAllData
    ActiveSheet.Range("$A$8:$Q$200").AutoFilter Field:=3, Criteria1:="3"
End Sub

Sub A()
    ActiveSheet.ShowAllData
    ActiveSheet.Range("$A$8:$Q$200").AutoFilter Field:=4, Criteria1:="a"
End Sub

Sub B()
    ActiveSheet.ShowAllData
    ActiveSheet.Range("$A$8:$Q$200").AutoFilter Field:=4, Criteria1:="b"
End Sub

Sub C()
    ActiveSheet.ShowAllData
    ActiveSheet.Range("$A$8:$Q$200").AutoFilter Field:=4, Criteria1:="c"
End Sub

Sub D()
    ActiveSheet.ShowAllData
    ActiveSheet.Range("$A$8:$Q$200").AutoFilter Field:=4, Criteria1:="d"
End Sub

Sub E()
    ActiveSheet.ShowAllData
    ActiveSheet.Range("$A$8:$Q$200").AutoFilter Field:=4, Criteria1:="e"
End Sub

Sub F()
    ActiveSheet.ShowAllData
    ActiveSheet.Range("$A$8:$Q$200").AutoFilter Field:=4, Criteria1:="f"
End Sub

Sub G()
    ActiveSheet.ShowAllData
    ActiveSheet.Range("$A$8:$Q$200").AutoFilter Field:=4, Criteria1:="g"
End Sub

Looking for any suggestions. Thanks
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try replacing...

Code:
ActiveSheet.ShowAllData

with

Code:
[COLOR=darkblue]If[/COLOR] ActiveSheet.FilterMode [COLOR=darkblue]Then[/COLOR] ActiveSheet.ShowAllData

or

[COLOR=darkblue]With[/COLOR] ActiveSheet
    [COLOR=darkblue]If[/COLOR] .FilterMode [COLOR=darkblue]Then[/COLOR] .ShowAllData
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]With[/COLOR]

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,214,530
Messages
6,120,071
Members
448,943
Latest member
sharmarick

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