我想知道如何访问条件格式中标题为“应用于”的列,并输入自己的条件。为了更好地参考,我已经包含了一张屏幕截图。
我添加条件格式语法的代码如下:
With Selection
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=" & c.Address & "=TRUE"
.
.
.
End With
我相信代码应该加在那里,但我只是找不到正确的语法。
更新:
我将我的代码更新为以下内容:
With Range(Cells(c.Row, "B"), Cells(c.Row, "N"))
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=" & c.Address
.FormatConditions(1).Interior.ColorIndex = 15 'change for other color when ticked
End With
这基本上会使得特定范围内与我放置复选框相关的行改变它们的背景颜色。 复选框位置由c.Address表示,其中'c'包含我选择放置复选框的单元格的位置。