VBA To Filter Conditionally Formatted coloured cells in multiple columns

SteveG1983

New Member
Joined
Mar 24, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi,
I'm fairly new to VBA and i'm trying to develop coding which will allow me to filter only the cells coloured 'Green' in the screenshot below, across several columns (conditional formatting determines the cell colour)

1711297721723.png



I've applied the following Macro/VBA as a test however when I run it, the 'Green' cells don't all appear (can i replace specific column numbers with a range within the 'AutoFilter Field' condition?);

Sub GreenFilter()
'
' GreenFilter Macro
'

ActiveSheet.Range("$e$18:$br$100").AutoFilter Field:=17, Criteria1:=RGB(146 _
, 208, 80), Operator:=xlFilterCellColor
ActiveSheet.Range("$e$18:$br$100").AutoFilter Field:=20, Criteria1:=RGB(146 _
, 208, 80), Operator:=xlFilterCellColor
ActiveSheet.Range("$e$18:$br$100").AutoFilter Field:=23, Criteria1:=RGB(146 _
, 208, 80), Operator:=xlFilterCellColor
ActiveSheet.Range("$e$18:$br$100").AutoFilter Field:=24, Criteria1:=RGB(146 _
, 208, 80), Operator:=xlFilterCellColor

End Sub

If there is anyone with any guidance/advice, it will be greatly appreciate.

Thanks and regards
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
do you insist on using VBA for this?
When you show only the green cells in one column you hide green cells from the others and you cannot show them ... so this method is not ok.
Best and easiest is to use a helper column and then use it to apply the filter and show all green cells (but not only the green ones - this setup of the data does not allow it).
For the helper column use a formula like:
Excel Formula:
=MAX(AT18:BA18)>TODAY()
 
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,596
Members
452,657
Latest member
giadungthienduyen

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