Hi,
Thanks for the wishes. I guess, following shall work. Only thing that you need to do is match colors (Shades of Red, Orange & Green) used in Cells L6, M6 & N6 in the rows where you want to set color filter as my code refers to these cells for color match. Currently they do not match except column L (Red). Especially the selectionchange event color setting.
The color filter is set in Cell K1. This was a bit of rework as I had not considered such possibility while doing the first part.
This is the main event which looks at which filter is being used: B1 or K1
[VBA]Public rTarget As Range
Public iCol As Integer
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Application.EnableEvents = False
If Target.Address = "$B$1" Then
Set rTarget = Target
Call HideSpecificRows
ElseIf Target.Address = "$K$1" Then
If Target.Value <> "None" Then
If Target.Value = "Red" Then iCol = 12
If Target.Value = "Orange" Then iCol = 13
If Target.Value = "Green" Then iCol = 14
Set rTarget = Range("B1")
Call HideColoredRows
Else
Set rTarget = Range("B1")
Call HideSpecificRows
End If
End If
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub[/VBA]
Some conditions needed shifting from above event to this routine.
[VBA]Private Sub HideSpecificRows()
Dim rToCheck As Range, r As Range
If rTarget.Value = "ALL" Then
Cells.EntireRow.Hidden = False
Else
Cells.EntireRow.Hidden = False
Set rToCheck = Range("A8:A" & Cells(Rows.Count, 1).End(xlUp).Row)
For Each r In rToCheck
If InStr(r.Value, rTarget.Value) = 0 Then
r.EntireRow.Hidden = True
Else
r.EntireRow.Hidden = False
End If
Next r
End If
End Sub[/VBA]
And before applying color filter it reworks the base filter in B1 as this sub calls Sub above "HideSpecificRows".
[VBA]Private Sub HideColoredRows()
Dim rColCheck As Range, r As Range
Call HideSpecificRows
Set rColCheck = Range("B8:B" & Cells(Rows.Count, 2).End(xlUp).Row) _
.SpecialCells(xlCellTypeVisible)
For Each r In rColCheck
If Cells(r.Row, iCol).Interior.Color <> Cells(6, iCol).Interior.Color Then _
r.EntireRow.Hidden = True
Next r
End Sub
[/VBA]
I am attaching the revised workbook.