Can use VBA to find .Interior.Color of a cell, but can't if Conditional Formatting sets the color

jfarc

Active Member
Joined
Mar 30, 2007
Messages
316
I see that I can test for and find the Color Index of a cell by using the following VBA code:

VBA Code:
colorCode = Range("S4").Interior.Color

But, the above code will not return the visible Color Index code of a cell that has Conditional Formatting where the rules of the Conditional Formatting has changed the Color to something else.

So, if the cell in question has been set to have the Color Green (Index=65280), but a Conditional Format rule has changed the cell color to Red(Index=255), then the above code returns the originally hard set color of Green-65280, but not Red-255, which is what the user sees when looking at the cell.

How can I find through VBA what the CondForm'd Color has been set to?
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
You can use the DisplayFormat property but only in a macro or event code... it will not work in a UDF (user defined function)...

colorCode = Range("S4").DisplayFormat.Interior.Color
 
Upvote 0
Solution

Forum statistics

Threads
1,213,553
Messages
6,114,279
Members
448,562
Latest member
Flashbond

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