VBA Conditional Format

Gliffix101

Board Regular
Joined
Apr 1, 2014
Messages
81
Hello,

I'm attempting to add conditional formatting based on a value and then filter on all cells NOT conditional formatted. I'm getting hung up on the .FormatConditions.Add line. Can someone take a look and let me know what I'm missing?

Code:
With Columns("AI:AI")
    .FormatConditions.Add Type:=xlExpression, Criteria1:=Array("Initiated", "Outstanding", "Requested", "No Tracking Item Created")
    With .FormatConditions(.FormatConditions.Count)
        .SetFirstPriority
        With .Interior
            .Color = RGB(255, 217, 102)
        End With
        StopIfTrue = False
    End With
End With


Rng.AutoFilter Field:=35, Criteria1:=RGB(255, 217, 102), Operator:=xlFilterNoFill
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
What condition are you trying to set with that code?

If you wanted the condition to check if the values in the array existed in the cell I would expect to see a formula that used MATCH or something similar rather than just an array of values.
 
Upvote 0
Hi Norie

If the Cell Value in Column AI equals Initiated, Outstanding, Requested, or No Tracking Item Created I want it to highlight the cell. Then, later in the code, I filter these out.

Ultimately, I'm trying to highlight those and then filter them out so I can copy all of the rest of the cells. I'm beginning to think the xlFilterNoFill might not work either?
 
Upvote 0
Hi Norie,

Thank you for pointing out the formula piece. With some additional research, I found what works:

Code:
With Columns("AI:AI")
    .FormatConditions.Add Type:=xlExpression, Formula1:="=OR(ISNUMBER(SEARCH(""Outstanding"",$AI1)),ISNUMBER(SEARCH(""Initiated"",$AI1)),ISNUMBER(SEARCH(""Requested"",$AI1)),ISNUMBER(SEARCH(""No Tracking Item Created"",$AI1)))"
    With .FormatConditions(.FormatConditions.Count)
        .SetFirstPriority
        With .Interior
            .Color = RGB(255, 217, 102)
        End With
        StopIfTrue = False
    End With
End With

I also was trying to figure out how to filter out the non-highlights, not thinking about just filtering on those not filtered (naturally filled white). So I used this code:

Code:
Rng.AutoFilter Field:=35, Criteria1:=RGB(255, 255, 255), Operator:=xlFilterCellColor

Thank you for helping me think about this differently.

Bill
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,183
Members
449,071
Latest member
cdnMech

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