View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Joe HM Joe HM is offline
external usenet poster
 
Posts: 92
Default Conditional Formatting Bug w/ relative formula?

Hello -

I have coded up the following to automatically set the Conditional
Formatting for a cell:

lLine = 28

With Range("D" & lLine )
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=$D" & lLine &
"=""X"""
.FormatConditions(1).Interior.ColorIndex = 3
.FormatConditions.Add Type:=xlExpression, Formula1:="=$D" & lLine &
"=""Y"""
.FormatConditions(2).Interior.ColorIndex = 5
End With

When I run it, the actual Formula is =D37="X" rather than =D28="X". If
I do a Range().Select and then the Selection.FormatConditions.XXX it
works fine. Any idea what that is all about? Am I doing something
wrong here?

Thanks,
Joe