VBA Format Conditions

M

Mark1

Can anybody tell me why I get the error message 'Expected: =' at the .Add
line? Thanks! h is a defined range of cells. I'm trying to conditionally
format several cells so that if they are greater than the cell two columns to
the left of them, the font will be green.

With h.FormatConditions
.Delete
.Add(xlCellValue, xlGreater, ActiveCell.Offset(0, -2))
End With
 
B

Bernie Deitrick

Mark,

You don't use the parens with the .Add unless you want to set a variable
equal to the returned value.

Also, you need to pass a valid cell address to the .Add, not the cell
itself:

With h.FormatConditions
.Delete
.Add xlCellValue, _
xlGreater, _
"=" & h(1, -1).Address(False, False)
End With

HTH,
Bernie
MS Excel MVP
 
Top