Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Erase filter with macro button

0 views
Skip to first unread message

bren

unread,
Jan 2, 2010, 9:41:23 AM1/2/10
to
Hi,

I have this code

Sub select()

Selection.AutoFilter Field:=3, Criteria1:="X"
End Sub

The idea is to assign it to a button and when clicking it filters all
x values, and if I click again on this button it deletes the filter. I
don´t know how to do this second step.

THANKS

Don Guillett

unread,
Jan 2, 2010, 10:23:38 AM1/2/10
to
One way
Sub ToggleFilter()
Set sn = Sheets("sheet7")
With sn.Range("a1:c21")
If sn.FilterMode = False Then

.AutoFilter Field:=3, Criteria1:="X"
Else
.AutoFilter
End If
End With
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
dguil...@austin.rr.com
"bren" <srt...@gmail.com> wrote in message
news:2956e727-72ac-4ab1...@u7g2000yqm.googlegroups.com...
Hi,

I have this code

Sub select()

Selection.AutoFilter Field:=3, Criteria1:="X"
End Sub

The idea is to assign it to a button and when clicking it filters all
x values, and if I click again on this button it deletes the filter. I

don�t know how to do this second step.

THANKS

bren

unread,
Jan 2, 2010, 12:56:19 PM1/2/10
to
Thanks. That worked really well!

0 new messages