Fliter multiple columns by color, blanking other cells in row

Torquil

New Member
Joined
May 17, 2020
Messages
4
Office Version
  1. 2019
Platform
  1. Windows
Hello,
I am trying to do what feels like the impossible.

I want to filter 4 columns by color displaying only cells that have the same color fill:
1652880120342.png

for example I want to only see the cells that are Green. so when the filter is applied the cell that are orange or grey are not shown.
I have tried
VBA Code:
ActiveSheet.Range("$D$12:$G$167").AutoFilter Field:=1, Criteria1:=RGB(198, 224, 180), Operator:=xlFilterCellColor
    ActiveSheet.Range("$D$12:$G$167").AutoFilter Field:=2, Criteria1:=RGB(198, 224, 180), Operator:=xlFilterCellColor
    ActiveSheet.Range("$D$12:$G$167").AutoFilter Field:=3, Criteria1:=RGB(198, 224, 180), Operator:=xlFilterCellColor
    ActiveSheet.Range("$D$12:$G$167").AutoFilter Field:=4, Criteria1:=RGB(198, 224, 180), Operator:=xlFilterCellColor
but i end up with nothing displaying even if there are green fields in the column.
what I want to achieve is a filter for green that would give me:
1652880077294.png



Long term vision is to have buttons to filter by color across the 4 columns.
Any ideas if 1 this is possible? I would also be open to a solution that copies and pastes the date to a separate sheet but I would prefer something to work like a filter on a single page.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
How are the cells getting the colour?
 
Upvote 0
Ok, how about
VBA Code:
Sub Torquil()
   Dim Cl As Range, Rng As Range
   For Each Cl In Range("D13:G167")
      If Cl.Interior.Color = 11859142 Then
         If Rng Is Nothing Then Set Rng = Cl Else Set Rng = Union(Rng, Cl)
      End If
   Next Cl
   If Not Rng Is Nothing Then
      Range("D13:G167").EntireRow.Hidden = True
      Rng.EntireRow.Hidden = False
   End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,499
Members
449,089
Latest member
Raviguru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top