Guinaba
Board Regular
- Joined
- Sep 19, 2018
- Messages
- 217
- Office Version
- 2016
- Platform
- Windows
Hello experts,
Have a toogle button in my sheet filtering a specific column (code below), the filtering criteria is cell (17,5).value. What I'd like to do is when the filter is still on if the cell (17,5).value is changed the filter automatically changes as well.
Have a toogle button in my sheet filtering a specific column (code below), the filtering criteria is cell (17,5).value. What I'd like to do is when the filter is still on if the cell (17,5).value is changed the filter automatically changes as well.
VBA Code:
Private Sub ToggleButton1_Click()
Dim LRow As Integer
With ActiveSheet
LRow = .Cells(.Rows.Count, "E").End(xlUp).Row
If ToggleButton1.Value = True Then
ToggleButton1.Caption = "Filter Item On"
ToggleButton1.BackColor = vbGreen
.Range("$A$21:$AF$" & LRow).AutoFilter Field:=4, Criteria1:=.Cells(17, 5).Value
Else
ToggleButton1.Caption = "Filter Item Off"
ToggleButton1.BackColor = vbWhite
.Range("$A$21:$AF$" & LRow).AutoFilter Field:=4
End If
End With
End Sub