条件格式错误VBA

时间:2017-03-28 12:06:06

标签: excel vba formatting conditional

我想知道是否有人能帮忙吗?!我在以下行收到错误:

.Add Type:=xlExpression, Formula1:= _
    "=IF($E1<>"",AND($E1<TODAY(),$F1=""Awaiting Information"")) = 1"

以下是代码。

Sub ConditionalFormat()

Sheets("NACO").Cells.FormatConditions.Delete

 With Worksheets("NACO").Columns("A:N").FormatConditions
**.Add Type:=xlExpression, Formula1:= _
    "=IF($E1<>"",AND($E1<TODAY(),$F1=""Awaiting Information"")) = 1"**
With .Item(.Count).Interior
    .Color = 255
End With

.Add Type:=xlExpression, Formula1:= _
    "=IF($E1<>"",AND($E1<TODAY(),$F1=""On Going"")) = 2"
With .Item(.Count).Interior
    .Color = 225
End With

.Add Type:=xlExpression, Formula1:= _
    "=IF($E1<>"",AND($E1<TODAY(),$F1=""Awaiting Quotation"")) = 3"
With .Item(.Count).Interior
    .Color = 255
End With

.Add Type:=xlExpression, Formula1:= _
    "=$F1=""On Going"" = 4"
With .Item(.Count).Interior
    .Color = RGB(247, 150, 70)
End With
End With
End Sub

有人可以解释为什么会发生错误吗?是否与&#34;&#34;?

1 个答案:

答案 0 :(得分:0)

您可以尝试将公式更改为此公式:

=IF(AND($E1<>"",$E1<TODAY(),$F1="Awaiting Information")=1