View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Conditional Formatting and Interior.ColorIndex

If you use this syntax it will produce the ColorIndex number you are looking
for.

MsgBox Range("G23").FormatConditions(2).Interior.ColorInd ex

The problem is that you cannot use a generic FormatConditions, it must be
specific as (1), (2) or (3).



"Farrar Tweety" wrote:

Windows XP Pro SP2
Excel 2002 SP3

Seems that cells that are conditionally formatted don't return an expected
Interior.ColorIndex value.

I am using this bit of code:

Set rng1 = Range("B20:P20")
For Each c1 In rng1.Cells
v1 = c1.Value
If v1 < "" Then
Set rng2 = Range(c1.Offset(3, 0), c1.Offset(32770, 0))
rng2.FormatConditions.Add xlCellValue, xlEqual, v1
rng2.FormatConditions(1).Interior.ColorIndex = 4
rng2.FormatConditions.Add xlCellValue, xlNotEqual, v1
rng2.FormatConditions(2).Interior.ColorIndex = 46
End If
Next c1

This works fine and colors the interiors as I would expect. However, if I
add this after the last line above

MsgBox Range("G23").Interior.ColorIndex 'G23 is colored red (46)

the message box says -4142.

What's up with that?

Any help greatly appreciated.

-gk-

GO TAR HEELS ! ! !