I would like to add conditional formatting to a cell, but the value for the condition is another cell.
The condition should go into this cell: Cells(x, cellcounter)
If Cells(x, cellcounter) > 0 then Cells(y, cellcounter) color RGB(153, 199, 112)
This is what I have come up with, but it gives me an error. What would be the correct syntax?
Cells(cell_quote_paid, cellcounter).FormatConditions.Add(Cells(cell_pending, cellcounter), xlGreater, "=0").Interior.Color = RGB(153, 199, 112)
Thx for the help!
In Excel 2010 there's no need for VBA.
You can apply the same rule to multiple cells using [Conditional Formatting] - [Manage Rules...], so all cells will turn red if condition cell goes from 0 to 1.
To do the same in VBA, use the following methods and properties:
{target range}.FormatConditions.Add Type:=xlExpression, Formula1:="=$A$1>0"
{target range}.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
{target range}.FormatConditions(1).Font.Color = RGB(153, 199, 112)
{target range}.FormatConditions(1).StopIfTrue = False
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.