2017-03-28 17 views
0

誰かがお手伝いできるかどうか疑問に思っていましたか?次の行にエラーが表示されます。条件付きフォーマットエラーVBA

.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 

誰かがエラーが発生している理由を説明してください。それは ""と関係がありますか?

+0

'$ E1 <>" "' $ E1 <> "'は二重にする必要があります –

+0

リテラル文字列の中にリテラルの二重引用符文字を含めると、引用符を二重にする必要があります。 "<>" "は$ E1にする必要があります<>" "" " –

+0

板張りのものを感じます"と私は思っていました。 –

答えて

0

あなたはこの1に数式を変更してみてください:

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

+0

ああ、もし私がAND/ORを使っているのならIF文は必要ありませんか? –

+0

@ShawnCartwright、実際にあなたの条件はわかりませんが、おそらくあなたは編集したバージョンを参照してください。 – Vityata