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

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
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?
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,222,152
Messages
6,164,248
Members
451,882
Latest member
Bigtop

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