Formatconditions color

HWL

Active Member
Joined
Dec 1, 2009
Messages
462
Excel 2007,
I'm doing a simple loop and trying to see what the formationconditions property will return but it is failing.
The error is object doesn't support this prop.


MsgBox ActiveSheet.Cells(x, y).FormatConditions.interior.color
Where x = a dynamic row number and y = a dynamic col number

I also tried MsgBox ActiveSheet.Cells(X, y).FormatConditions.FormatCondition.Interior.Color with same error.

All I'm trying to do is get the interior color of the conditional formatted cell. Any ideas? Thanks

see: FormatConditions Object [Excel 2007 Developer Reference]
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Thanks venkat, but that is only going to give me the font color. I'm trying to access the conditional cell color
 
Upvote 0
I've figured out how to make this work but only if the first condition is a match. How do I know which condition is active? Currently I am just matching the first condition whether it is active or not.

SAMPLE
'conditional colors
If ActiveSheet.Cells(X, y).FormatConditions.Count > 0 Then
rnger = ConvertToLetter(Val(y)) & X & ":" & ConvertToLetter(Val(y)) & X
If ActiveSheet.Range(rnger).FormatConditions(1).Interior.Color = Label8.BackColor Then
condhit = 1
End If
End If

That code is within a loop of X and y and refers to a function helper to convert the column numbers into letters.
 
Upvote 0
ANSWERING my own questions :p
Using Evaluate (ActiveSheet.Range(rnger).FormatConditions(1).Formula1) I can check if the underlying formulas are true or not. See modified code:

'conditional colors
If ActiveSheet.Cells(X, y).FormatConditions.Count > 0 Then
rnger = ConvertToLetter(Val(y)) & X & ":" & ConvertToLetter(Val(y)) & X
If ActiveSheet.Range(rnger).FormatConditions(1).Interior.Color = Label8.BackColor And Evaluate(ActiveSheet.Range(rnger).FormatConditions(1).Formula1) = True Then
condhit = 1
End If
End If
 
Upvote 0

Forum statistics

Threads
1,203,236
Messages
6,054,300
Members
444,715
Latest member
GlitchHawk

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