View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bobby[_4_] Bobby[_4_] is offline
external usenet poster
 
Posts: 53
Default Conditional Formatting and VBA

On Feb 23, 6:44*pm, GS wrote:
Bobby explained on 2/23/2012 :

Hi,
I have a sheet with conditional formatting. If the cell contains a
zero then it turns yellow and it works fine. I created a macro to add
all white cells containing a number greater then zero. To do that I
check the Interior.ColorIndex. The funny part is If the cell is yellow
because of the conditional formatting(meaning that the value is zero)
the VBA code with the Interior.ColorIndex sees it has a code 2(white
cell instead of yellow)! Is this normal and how can I fix it?
Thank's ahead.


The cell color is always the default value unless changed by CF
(ConditionalFormatting). Interior.ColorIndex will persist to return the
default color regardless of what color CF is rendering.

What I find a lot of folks do is to have both true/false colors in
play. This can be problematic (as you've discovered) depending on
what's happening and so I find it easier to NOT PLAY the color game.
That means I set the cell shading to a default color and let CF handle
changing it based on how the logic of my criteria applies.

If you're trying to test if a cell is changed by CF then test for the
criteria you used for CF conditions to apply. If there's no match then
the cell *should* be the default color. No color is the normal default
but you can manually change that as desired, leaving CF to make changes
when condition criteria is TRUE..

--
Garry

Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup!
* * comp.lang.basic.visual.misc
* * microsoft.public.vb.general.discussion


Thank's Garry
If I may I do use the color as a switch. If it's yellow it's paid,
white is not paid. If I understand what you are saying I should change
my approach right?