Checkboox and Undoing

xenoborg

New Member
Joined
Jul 3, 2007
Messages
9
I have a list of data that I am trying to be able to quickly filter a list with checkboxes. Currently I have this bound to several checkboxes (one for each column)

Private Sub CheckBox1_Click()
Selection.AutoFilter Field:=27, Criteria1:="<>0", Operator:=xlAnd
End Sub

They successfully sort my data when checked, but don’t undo themselves when unchecked. Is there a way I can make them do with, preferably with check boxes?

Thanks

PS. It’s just a looks thing, but is there a way to reverse the states of the check box so that when it’s unchecked it does the filter?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

xenoborg

New Member
Joined
Jul 3, 2007
Messages
9
Usin record Ive found that I can do

Selection.AutoFilter Field:=27

to revert it.

Im not great with VB syntax, how can I make it so if its checked it will do one, and if its unchecked it will do the other?
 

xenoborg

New Member
Joined
Jul 3, 2007
Messages
9
OK, so now I have this:

Sub Filter()
If AU10 = "True" Then
Selection.AutoFilter Field:=25, Criteria1:="<>0", Operator:=xlAnd
Else
Selection.AutoFilter Field:=25
End If
End Sub

but, when I run it, it doent do anything.
AU10 contains TRUE or FALSE based on the state of my checkbox
The two autofilter macros work fine independently, so I think I messed up constructing the if statement.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,895
Messages
5,766,978
Members
425,392
Latest member
Booknerd

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
Top