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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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,215,357
Messages
6,124,482
Members
449,165
Latest member
ChipDude83

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