【发布时间】:2017-03-28 12:06:05
【问题描述】:
我想知道是否有人可以帮忙?!我在以下行收到错误:
.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
有人能解释一下为什么会发生错误吗?跟“”有关系吗?
【问题讨论】:
-
$E1<>""等于$E1<>"需要加倍 -
当您尝试在文字字符串中包含文字双引号字符时,您需要双引号。所以 $E` "" 需要是 $E1 """"
-
感觉有点像木板。它的“”,正如我所想的那样。令人沮丧。我遇到的问题是它添加了条件格式但没有将它们应用于范围。我做错了什么?
标签: excel vba formatting conditional