I am conditionally formatting a range of cells. I want to do greater than and less than another cell value. I have found this code online that lets me do that but I was wondering if there is a way to skip formatting if the condition cell is blank.
Example: I want to highlight "G14" red if the value is greater than "D14"+"E14". Vise versa for minus. If the value of "E14" is blank it still make s it red because it is acting as if it is zero.
Here is my code:
'Format Measured
Dim rg As Range
Dim cond1 As FormatCondition, cond2 As FormatCondition, cond3 As FormatCondition
Set rg = Range("G14", Range("G14").End(xlDown))
'clear any existing conditional formatting
rg.FormatConditions.Delete
'define the rule for each conditional format
Set cond1 = rg.FormatConditions.Add(xlCellValue, xlGreater, "=$D14+$E14+$H14")
Set cond2 = rg.FormatConditions.Add(xlCellValue, xlLess, "=$D14-$F14")
'define the format applied for each conditional format
With cond1
.Font.FontStyle = "Bold"
.Font.Color = vbRed
End With
With cond2
.Font.FontStyle = "Bold"
.Font.Color = vbRed
End With
SpecialCellsor an adaptation of your formula to include"<>"""D14orE14is blank, or justE14?