I am looking to use multiple (5) checkboxes to filter a single column in an excel table. The column to be filtered contains several markers namely
"","r","x","s","t"
My aim is to tick several boxes and include all the columns with said marker. Using straightforward methods results in the previous filter being cleared instead of being "added".
Here a picture of my (now two) tracking columns, one containing the identifier and another hidden converting that too the checkbox captions using ifs statements so @zac's solution works.
I have a looked around a lot and found a thread on MrExcel where some code was provided however I was unable to adapt it to my exact needs. Sadly whichever button I press it keeps defaulting to the blank ("") marker.
Below is my code for a sub that should be called by each checkbox.
Background info:
The identifier value are defined in a table and assigned a dynamic named range "tracking"
The column to be filtered is called ("Project Flag")
The code is contained in a seperate module
Sub Project_Filter()
Dim objcBox As Object
Dim cBox As Variant
Set Dbtbl = Sheets("Database").ListObjects("Entire")
ReDim cBox(0)
Dim trackers() As String
Dim i As Integer
Dim x As Variant
i = -1
For Each x In Range("Tracking").Cells 'reading named range into array
i = i + 1
ReDim Preserve trackers(i) As String
trackers(i) = x.Value
Next x
Application.ScreenUpdating = False
With Sheets("Database")
For Each objcBox In .OLEObjects
If TypeName(objcBox.Object) = "CheckBox" Then 'looking for checkboxes
If objcBox.Object.Value = True Then
cBox(UBound(cBox)) = trackers(i) 'setting cbox array as nth trackers value
i = i + 1
ReDim Preserve cBox(UBound(cBox) + 1)
End If
End If
Next
If IsError(Application.Match((cBox), 0)) Then
MsgBox "Nothing Selected"
Exit Sub
End If
ReDim Preserve cBox(UBound(cBox))
If Not .AutoFilterMode Then
Dbtbl.Range.AutoFilter
Dbtbl.Range.AutoFilter Field:=Dbtbl.HeaderRowRange.Find("Project Flag").Column, Criteria1:=Array(cBox)
End If
End With
Application.ScreenUpdating = True
End Sub
So after some trial and error i found out that the array cbox() only contains the first value of my trackers array, hence it only filtering the blank entries. No idea what causes that but thought it might be noteworthy

Varianttypes are convenient and useful at times, try true declarations for your variables - ZacDim As Boolean? Cause if not i'm a bit confused. Quite the rookie in terms of coding in general - Nick