PDA

View Full Version : Solved: Conditional Formating - Formula Help



Philcjr
01-11-2010, 08:34 AM
Can someone please help me with this formula:


sFormula3 = "=AND(D" & Z & ">=0.5*$C" & Z - 1 & ",D" & Z & "<=0.8*$C" & Z - 1
.FormatConditions.Add Type:=xlExpression, Formula1:=sFormula3
With .FormatConditions(3).Font
.Bold = True
.ColorIndex = 1
End With
.FormatConditions(3).Interior.ColorIndex = 6

It is trying to putting an extra set of quotations around the formula... causing this not to enter in the conditional format. "Z" would be the Row Number

mbarron
01-11-2010, 09:28 AM
You don't have the closing ")" for the AND statement and you aren't closing off the string for your formula>
try:
"=and(d" & Z & ">=.05*$c" & Z - 1 & ",d" & Z & "<=0.8*$c" & Z & "-1)"

Philcjr
01-11-2010, 09:44 AM
mbarron - Thanks, I feel pretty stupid for missing that.

Philcjr
01-11-2010, 09:45 AM
The final code chage is this:

sFormula3 = "=AND(D" & Z & ">=0.5*$C" & Z - 1 & ",D" & Z & "<=0.8*$C" & Z - 1 & ")"
.FormatConditions.Add Type:=xlExpression, Formula1:=sFormula3
With .FormatConditions(3).Font
.Bold = True
.ColorIndex = 1
End With
.FormatConditions(3).Interior.ColorIndex = 6