View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
roadkill roadkill is offline
external usenet poster
 
Posts: 173
Default Programming Formula for Cond. Format yields different formula

Since you asked, I tried it and it appears that the formula comes through
unchanged. Unfortunately, I need for relative reference.

Any idea why absolute is okay but relative is not?
Will

"Jim Cone" wrote:


Have you tried it with absolute references for both columns and rows?...
Formula1:="=$J$3 = $U$2"
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"roadkill"
wrote in message
I'm trying to set conditional formatting constraints programmatically. I
started out constructing the conditions equation from variables but, in
troubleshooting, have simplified to the point where I'm basically just
writing the string directly - AND IT STILL DOESN'T WORK!!!

My code is below. The old conditional formatting gets deleted and new
formatting goes to the right cell. It's just that the wrong formula (and not
always the same) is there when I check via Format/Cells. For example, for
the first condition formula I've seen both "=$J2 = U$2" and "=$J2 = X$2"
(instead of "=$J3 = U$2"). The second conditional formula seems to always
follow the first as far as what deviates from what I'm trying to apply.

With ActiveSheet.Range(Cells(PCTROW, intColN + 1), Cells(PCTROW, intCol1 +
intNumWks - 1))
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, _
Formula1:="=$J3 = U$2"
.FormatConditions(1).Interior.ColorIndex = RED
.FormatConditions.Add Type:=xlExpression, _
Formula1:="=$J3 = U$1"
.FormatConditions(2).Interior.ColorIndex = BLUE
.Interior.ColorIndex = GREEN
End With

Any ideas?

Thanks,
Will