Autofilter 2 Criteria Issue

nniedzielski

Well-known Member
Joined
Jan 8, 2016
Messages
598
Office Version
  1. 2019
Platform
  1. Windows
I am auto-filtering on a sheet right now that will filter out anything not highlighted:

Code:
ActiveSheet.Range("A:D").AutoFilter Field:=2, Operator:= _
                    xlFilterNoFill

I want to now tack onto this code to make it auto-filter for anything not highlighted or anything highlighted red. How can I add on to this?

thanks,
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Try using the Macro Recorder while you do the filtering by hand.
That should give you the syntax needed.
 
Upvote 0
How would I do this by hand? Excel doesnt seem to want to allow me to filter for more than one color in the drop down.
 
Upvote 0
You're right, looks like you can only filter by a single color. If the autofilter can't do it, then macro can't either.
How are the cells colored? By hand, or by conditional formatting ?

If by conditional format, then you can filter by that same criteria.
 
Upvote 0
they are colored by Macro code, which means i need to rethink about the way they are being colored int he first place,

thanks,
 
Upvote 0
which means i need to rethink about the way they are being colored int he first place,

Cell Color is NOT Data that can be querried and parsed.
It's really only meant for your eyes, to make your sheet look pretty.

I would consider alternate methods to 'flag' cells for certain criteria.
Like putting text values in an alternate column..
If A2 is to be colored Red by your macro, then your macro could also put a certain text value in B2 for example.
Then you can filter column B for that word.


Or again, make the autofilter use the same criteria your macro uses to choose which color to put in the cell.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

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