我想知道如何访问条件格式中标题为“适用于”的列并输入我自己的条件。
我提供了一个屏幕截图以供更好的参考。
我在条件格式中添加语法的代码是,
With Selection
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=" & c.Address & "=TRUE"
.
.
.
End With
我相信代码应该添加到那里,但我只是找不到正确的语法。
Update :
我更新了我的代码,看起来像这样,
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”包含我选择放置复选框的单元格的位置。
你需要做这样的事情(Range("A25")
这正是您将要找到的):
With Range("A25")
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, _
Formula1:="=" & c.Address
'.
'.
'.
End With
并且没有必要写"=" & c.Address & "=TRUE"
,你可以只使用"=" & c.Address
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)