I need to change the cell color if the cell value is bigger than another cell in other column. for example value in G6 > D6, and this rule need to apply to the whole column.
I used formatConditions implemented some code, but the result is not very correct.
Set rngCell = Cells(6, 7)
Set objCF = rngCell.FormatConditions.Add _
(Type:=xlCellValue, Operator:=xlGreater, Formula1:=rngCell.offset(, -3))
'set formats for new CF
With objCF
.Font.ColorIndex = 26
.Interior.ColorIndex = 19
End With
With this code , I got the result rule is: Cell Value > 18 (18 is the cell value of D6)
But what I want is rule like: Cell value > $D6
Anyone can help?
This is the method I used (you can easily create and modify one using the Macro Recorder). The formatting will be applied to the seventh column (“G”). The formula is self-explanatory. Note that since the formula is a string you can concatenate the columns / rows dynamically.