Hello all,
My first post in the forum! I'm trying to create and control an autofilter using a check box control, for a single column.
The data is simply a "y" or left blank, and I want a check box control to filter all the rows with "y" (if checked), and display all results (blank or "y") if unchecked. Preferably, I would like the control caption to be descriptive, rather than the criteria.
I had started with an approach using the following, though I freely admit I could be on the wrong track (and I'm a VBA newbie):
Sub Data_CheckBox1_Click()
If CheckBox = False Then
Call Macro1
Else
Call Macro2
End If
End Sub
With:
Sub Macro1()
Worksheets("Data").Range("N9").AutoFilter _
Field:=2, _
Criteria1:="Y", _
VisibleDropDown:=True
End Sub
Sub Macro2()
Worksheets("Data").Range("N9").AutoFilter _
Field:=2, _
Criteria1:="", _
Operator:=2, _
Criteria2:="Y"
End Sub
That seems to work for filtering the "y" values. But I couldn't get anywhere with a Macro2 to show all results. It doesn't run when I uncheck the box
Any advice?
EDIT: I should add that I'll be doing the same thing for multiple columns.
Bookmarks