Since you didn't provide any details about or a sample of your workbook, here is a basic working example.
Instead of check boxes, I have used Marlett "check boxes". Marlett is a font whose "a" character is checkmark. Using VBA code we can turn this checkmark on and off to indicate selection. In the attachment, click in cells B2:B4 to see this in action.
Here is the code in the attached workbook. Obviously, you will have to adapt it per your actual workbook.
In the worksheet module:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("B2:B4")) Is Nothing Then
Target.Font.Name = "Marlett"
If Target = vbNullString Then
Target = "a"
Else
Target = vbNullString
End If
End If
End Sub
In a standard module and assigned to a button on the sheet:
Option Explicit
Sub Filter_andP_Print()
Dim c As Range, rPrintArea
Application.ScreenUpdating = False
Set rPrintArea = Sheet1.Range("a7").CurrentRegion.SpecialCells(xlCellTypeVisible)
With Sheet1
If .Range("B1").Value = "" And _
.Range("B2").Value = "" And _
.Range("B3").Value = "" Then
MsgBox ("No filter selections are chosen - nothing to do!"), vbExclamation
Exit Sub
End If
.AutoFilterMode = False
.PageSetup.PrintArea = ""
.Range("A7").CurrentRegion.AutoFilter
On Error Resume Next
For Each c In .Range("B2:B4")
Select Case c.Value
Case "a"
.Range("A7:B7").AutoFilter Field:=1, Criteria1:=c.Offset(0, -1).Value
.PageSetup.PrintArea = rPrintArea.Address
.PrintOut
End Select
Next c
.AutoFilterMode = False
.Range("B2:B4").ClearContents
.PageSetup.PrintArea = ""
End With
Application.ScreenUpdating = True
End Sub
Bookmarks