我想知道如何访问标题为“适用于”的条件格式的列并输入自己的条件。 我已经包含了一个截图,以供参考。使用VBA将条件格式应用于一系列单元格
我在条件格式添加代码的语法是,
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”包含我选择放置复选框的单元格的位置。
谢谢,你的线索帮助我很多 – winhung