MS Project和VBA IF FORMULA

时间:2014-11-17 08:58:41

标签: vba ms-project

我必须在Ms-Project和VBA中制作类似的东西,但是在公式中:

If Number2=1 then 
    Duration=4
Else
    Duration=5
End if

我有这段代码:

CustomFieldSetFormula FieldID:=pjCustomTaskDuration1, Formula:="Iff(Number2=1;Duration=4;Duration=5)"
CustomFieldPropertiesEx FieldID:=pjCustomTaskDuration1, Attribute:=pjFieldAttributeFormula, SummaryCalc:=pjCalcFormula, GraphicalIndicators:=False, AutomaticallyRolldownToAssn:=False
CustomFieldPropertiesEx FieldID:=pjCustomTaskDuration1, Attribute:=pjFieldAttributeNone, SummaryCalc:=pjCalcNone, GraphicalIndicators:=False, AutomaticallyRolldownToAssn:=False

1 个答案:

答案 0 :(得分:0)

你很亲密。您需要的公式是:IIf([Number2]=1,[Duration4],[Duration5])。请注意,该函数名为内联If ,因此缩写为IIf,而不是IFf。