[英]Conditional formatting VBA different cell as condition
我想將條件格式添加到一個單元格,但條件的值是另一個單元格。
條件應該進入此單元格: 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)
謝謝!
在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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.