Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Format and VBA
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Format and VBA
Sandy,
Your code worked OK for me. (office 2003). "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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Format and VBA
Just to add to Ron's response.
It's usually lots easier to evauate the formula in the conditional formatting dialog (well, if you know the formula). But if you really want to get the conditional formatting color, you could use some code from Chip Pearson's site--it's not for the faint of heart! http://www.cpearson.com/excel/CFColors.htm 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 -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional Format and VBA
No it didn't!! Ignore this idiot!
"Toppers" wrote: Sandy, Your code worked OK for me. (office 2003). "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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
New Conditional Format Overriding Previous Conditional Format | Excel Discussion (Misc queries) | |||
How to create a conditional format that changes the number format | Excel Discussion (Misc queries) | |||
Multiple conditional on conditional format formula | Excel Programming | |||
Multiple conditional on conditional format formula | Excel Programming | |||
Keep format after paste from other worksheets - conditional format or EnableControl solution doesn't work | Excel Programming |