Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a variable that tells if t

Status
Not open for further replies.

larryww

Programmer
Mar 6, 2002
193
US
Is there a variable that tells if the conditional formatting has been tripped?

More on my specific quest: I have a routine that looks for shaded cells with
For Each c In ActiveSheet.UsedRange
If c.Interior.Color <> ActiveWorkbook.Styles.Application.Cells.Interior.Color Then

However this apparently doesn't catch conditionally formatted cells. c.Color doesn't get it. Since there's no @#$%ing c.BackgroundColor or c.PatternColor, what can I reference that has the conditional formatting?

Well, there is c.FormatConditions.Interior.Color; but it seems to always be the conditional color - i.e., this alone is not triggered by the &quot;conditional condition.&quot;

So, my other question is, is there a variable that contains the displayed color?

Better still, is there a way in code to tell if the conditional formatting has been tripped?
 
Larry,

You gave a good hint using FormatConditions.

Here's something that msy be useful - it returns the font colorindex of the cell conditionally formatted. You can identify the cell or any of the formatted properties - check out help on FormatConditions...
Code:
Sub WhatFormats()
    For Each cell In ActiveSheet.Cells(1, 1).CurrentRegion
        cell.Select
        For Each FormatCondition In cell.FormatConditions
            
            MsgBox FormatCondition.Font.ColorIndex
        Next
    Next
End Sub
Hope this helps :) Skip,
metzgsk@voughtaircraft.com
 
I'm still looking for the answer if anyone can help.
Thanks for answering, but that gave no new information.

Does anyone know how to detect in code when a conditional format kicks in, short of coding the condition(s) itself?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top