View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default conditional formatting in vba

Activecell was use as a representative range object.

Every single cell maintains its colorindex value for both
interior.colorindex and font.colorindex regardless of what color is being
shown by conditional formatting.

If you color a cell red manually, then apply a conditional format that makes
the cells (b9 for example) yellow,

msgbox Range("B9").Interior.ColorIndex

willl display 3 for red.

there is no reason to try to store the original color anywhere, nor is there
any provision for you to do so.

--
Regards,
Tom Ogilvy


"Gulli" wrote:

Hi Tom,

thanks for quick response. Is your suggestion correct only for ActiveCell ?
The problem is, I loop through a matrix of cells starting from an activecell
somewhere else. So all the target cells whose value will conditionally change
won't become active. Depending on input in "Source"Cell the values in
TargetCells will often flip between 0, empty or same Value as cell above and
another value which has to be shown.
Since worksheet.cells(r, c).font.color and .colorindex reflect always the
currently given value and activecell still remains on start-Cell, I found no
location, where the regular fontcolor is stored. Could i use the Color-field
"worksheet.cells(r, c).FormatConditions.Item1.Interior.Color" and store the
normal color ?

regards
gulli


I

"Tom Ogilvy" wrote:

Activecell.Interior.ColorIndex
Activecell.font.colorIndex

never changes regardless of what conditional formatting is displaying.

--
Regards,
Tom Ogilvy


"Gulli" wrote:

Hi anyone,

recently i put all worksheet formula into vba. Application now runs quite
fast except for checking each cell having conditional formula to make null,
zero-values and cells having the same value as the cell above invisible by
using backgroundcolor as fontcolor.
Changing the color within vba-code itself is not the problem. But I will
loose information about regular cell-color once I change FontColor. In the
next run it has to be changed back to regular color. I wonder, where
microsoft stores the "regular" coloring of a cell since the conditional
formula only knows the conditional color.

regards
willi