Hello,
Looking for a solution for a dashboard type sheet. Where if the user uses the dashboard sheet and applies a filter, it will apply the same filter to all the other sheets.
Tried searching a lot but can't find a fitting solved solution. I've been using a form before but I'm making some changes to the report where I need to use a drop down feature to apply the filter to other sheets. Here is the code I was using for the form:
Form Code
Looking for a solution for a dashboard type sheet. Where if the user uses the dashboard sheet and applies a filter, it will apply the same filter to all the other sheets.
Tried searching a lot but can't find a fitting solved solution. I've been using a form before but I'm making some changes to the report where I need to use a drop down feature to apply the filter to other sheets. Here is the code I was using for the form:
Code:
Sub AutoFilter_AllSheets(Crit1 As String, Crit2 As String, Crit3 As String, Crit4 As String, OR_Btn As String)
Dim sht As Worksheet, Opr As Long
If OR_Btn = True Then Opr = xlOr Else Opr = xlAnd
For Each sht In ActiveWorkbook.Worksheets
If InStr("Metrics", sht.Name) = 0 Then
'For Each sht In Worksheets
With sht
If Len(Crit1) <> 0 And Len(Crit2) Then _
.ListObjects(1).Range.AutoFilter Field:=1, Criteria1:=Crit1, Operator:=Opr, _
Criteria2:=Crit2
If Len(Crit1) <> 0 And Len(Crit2) = 0 Then _
.ListObjects(1).Range.AutoFilter Field:=1, Criteria1:=Crit1
If Len(Crit3) <> 0 And Len(Crit4) Then _
.ListObjects(1).Range.AutoFilter Field:=2, Criteria1:=Crit3, Operator:=Opr, _
Criteria2:=Crit4
If Len(Crit3) <> 0 And Len(Crit4) = 0 Then _
.ListObjects(1).Range.AutoFilter Field:=2, Criteria1:=Crit3
End With
End If
Next sht
End Sub
Sub Show_AutoFilterEntryForm()
AutoFilter_EntryForm.Show
With AutoFilter_EntryForm
.OR_Btn.Value = True
.Cancel_Btn.Value = False
End With
End Sub
Code:
Private Sub OK_Btn_Click()
If TB_Criteria1.Value = vbNullString And TB_Criteria3.Value = vbNullString Then
MsgBox "No Auto Filter Criteria entered." & Chr(13) & Chr(13) & _
"Try Again or click CANCEL to quit.", vbOKOnly, "Blank Entry Response"
Exit Sub
End If
Unload AutoFilter_EntryForm
Call AutoFilter_AllSheets(TB_Criteria1.Value, TB_Criteria2.Value, TB_Criteria3.Value, TB_Criteria4.Value, _
OR_Btn.Value)
End Sub
Private Sub CLEAR_Btn_Click()
'For Each sht In Worksheets
For Each sht In ActiveWorkbook.Worksheets
If InStr("Metrics", sht.Name) = 0 Then
With sht
.ListObjects(1).Range.AutoFilter Field:=1, Criteria1:=Null
.ListObjects(1).Range.AutoFilter Field:=2, Criteria1:=Null
End With
End If
Next sht
Unload AutoFilter_EntryForm
End Sub
Private Sub CANCEL_Btn_Click()
Unload AutoFilter_EntryForm
End Sub