View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Conditional Format and VBA

On Sun, 27 Mar 2005 08:39:08 -0800, "Sandy"
wrote:

I have certain cells set to colorindex = 6 using Conditional Formatting.

I am trying via vba to act on these cells when encountered. When I try to
return the color value such as

xColor = Range("A1").Interior.ColorIndex

I get an incorrect result.

How do I do this and is there a way to set conditional formats vis VBA.

Thanks,

Sandy


To your 2nd question, look at the FormatCondition Object to set conditional
formatting within VBA.

With regard to your first question, you need to look at the contents of the
cell and the applicable FormatCondition. I recall it was explained to me that
Conditional Formatting doesn't really change the color "assigned" to the
particular object. As a matter of fact, if you conditionally format a
previously unformatted cell, the font colorindex remains "Automatic" and the
interior colorindex remains "None" (see XlColorIndex Constants).


--ron