有人可以帮助我在我下面的查询。我试图选择多列与最后一行和应用条件格式,但它不是在我尝试的方式工作。
工作一:
Dim lr As Long
With Range("E:E,F:F,H:H")
.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=0"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
.FormatConditions(1).Interior.Color = 13561798
.FormatConditions(1).StopIfTrue = False
End With
这一个不起作用:
Dim lr As Long
lr = Cells(Rows.Count, 1).End(xlUp).Row
With Range(""E2:E" & lr,"F2:F" & lr,"H2:H" & lr)
.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=0"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
.FormatConditions(1).Interior.Color = 13561798
.FormatConditions(1).StopIfTrue = False
End With
我尝试对包含错误“#N/A”的单元格应用颜色,但它不起作用。
Dim lr As Long
lr = Cells(Rows.Count, 1).End(xlUp).Row
With Range(""E2:E" & lr,"F2:F" & lr,"H2:H" & lr)
.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=#N/A"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
.FormatConditions(1).Interior.Color = 13561798
.FormatConditions(1).StopIfTrue = False
End With
任何帮助一个以上2查询将不胜感激。
1条答案
按热度按时间baubqpgj1#
试试这个:
FormatConditions.Add
返回刚刚添加的条件,因此您可以在With
块中使用它。还修复了您的Range()
调用。针对#N/A