我有以下代码,并且正在将我的头撞到墙上,为什么它不起作用。当使用范围为 $K10 的注释行时,当我分配一个命名范围 rngValidation 时它工作正常,它不起作用。“ptrValidationCells”的定义名称范围设置为$K10。
Sub FormatConditions_2()
Dim rngToFormat As Range
Dim rngValidation As Range
Set rngToFormat = ActiveSheet.Range("inpInputCells")
Set rngValidation = ActiveSheet.Range("ptrValidationCell")
' rngToFormat.FormatConditions.Add Type:=xlExpression, Formula1:="=$K10<>FALSE"
rngToFormat.FormatConditions.Add Type:=xlExpression, Formula1:="=rngValidation <>FALSE"
With rngToFormat.FormatConditions(2).Interior
.PatternColorIndex = xlAutomatic
.Color = RGB(255, 192, 0)
.TintAndShade = 0
End With
With rngToFormat.FormatConditions(2).Font
.Bold = True
.Italic = False
.Color = RGB(192, 0, 0)
.TintAndShade = 0
End With
End Sub
感谢您的帮助