AutoFilter out cells by colour

j4ttlife

New Member
Joined
Feb 2, 2022
Messages
30
Platform
  1. Windows
  2. MacOS
Hi all,

I'm trying to filter out certain cells in a column that I have filled as green. I only want to see the cells that are not green.

Normally I filter out by using the following code change the colour of certain cells and it works okay:

To change the colour of certain cells I use:
VBA Code:
Cells(i, 22).Interior.Color(38, 201, 218)

and then to filter out I use:
VBA Code:
my_sheet.Range("A1").AutoFilter field:=22, Criteria1:=RGB(38, 201, 218), Operator:=xlFilterCellColor

However, this time I have change the cell colours using:
VBA Code:
cell.Interior.ColorIndex = 4

This time I have used a ColorIndex instead of the color codes, but I'm unsure how to filter these out.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
If you record a macro whilst manually filtering on that colour, the macro will show you the RGB value
 
Upvote 0
If you record a macro whilst manually filtering on that colour, the macro will show you the RGB value
Thanks Fluff. I managed to resolve that issue using the macro recorder.

However, I made a mistake in my original code that I posted above.

The code above actually filters out all the cells that are NOT equal to RGB(38, 201, 218).

Is it possible to filter out cells that ARE equal to RGB(38, 201, 218) ?
 
Upvote 0
You can filter for "No Fill" but not to exclude only a certain colour.
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

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