我想将条件格式添加到单元格,但条件的值是另一个单元格。
条件应该进入此单元格:Cells(x, cellcounter)
If Cells(x, cellcounter) > 0 then Cells(y, cellcounter) color RGB(153, 199, 112)
这是我提出的,但它给了我一个错误。什么是正确的语法?
Cells(cell_quote_paid, cellcounter).FormatConditions.Add(Cells(cell_pending, cellcounter), xlGreater, "=0").Interior.Color = RGB(153, 199, 112)
请求帮助!
答案 0 :(得分:0)
在Excel 2010中,不需要VBA。
您可以使用[条件格式] - [管理规则...]将相同的规则应用于多个单元格,因此如果条件单元格从0变为1,则所有单元格都将变为红色。
要在VBA中执行相同操作,请使用以下方法和属性:
{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