jamescooper
Well-known Member
- Joined
- Sep 8, 2014
- Messages
- 834
Hello, trying to use a checkbox to filter a sheet. The CheckBox3.Caption works, but when I add further filters, CheckBox4 and CheckBox5 it doesn't; any ideas please?
VBA Code:
Private Sub CommandButton1_Click()
If OptionButton1.Value And OptionButton3.Value = True Then
Lastrow = Sheets("Data - Accidents").Cells(Rows.Count, "A").End(xlUp).Row
'Application.Visible = False
With Sheets("Data - Accidents")
.Range("A1:AS" & Lastrow).AutoFilter Field:=8, Criteria1:="Employee"
.Range("A1:AS" & Lastrow).AutoFilter Field:=45, Criteria1:=TextBox2
If CheckBox3.Value = True Then
.Range("A1:AS" & Lastrow).AutoFilter Field:=39, Criteria1:=CheckBox3.Caption
If CheckBox4.Value = True Then
.Range("A1:AS" & Lastrow).AutoFilter Field:=39, Criteria1:=CheckBox4.Caption
If CheckBox5.Value = True Then
.Range("A1:AS" & Lastrow).AutoFilter Field:=39, Criteria1:=CheckBox5.Caption
End If
End If
End If
End With
End If
End Sub