Toggle button/checkboxes

xenoborg

New Member
Joined
Jul 3, 2007
Messages
9
I have added some check boxes that will sort my data, in this case removing rows with values of 0. Currently, I have a checkbox with
Code:
Private Sub CheckBox1_Click()
    Selection.AutoFilter Field:=27, Criteria1:="<>0", Operator:=xlAnd
End Sub

It filters the way I want when I check it, but when I uncheck it, it doesn’t go back to what it was before, is this possible to do?

I tried using the same code with a few other button types like toggle, and it did the same thing. I would prefer to use a checkbox, but any type is fine.

Thanks


PS. Its not as important, but I was also wondering if it was possible to reverse it so that it filters things out when its not checked, and doesn’t filter when it is checked.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Code:
Private Sub CheckBox1_Click()
    If CheckBox1.Value = True Then
        Selection.AutoFilter Field:=27, Criteria1:="<>0", Operator:=xlAnd
    Else
        Selection.AutoFilter Field:=27
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,715
Members
448,985
Latest member
chocbudda

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