MS Project and VBA IFF FORMULA

709 views Asked by At

I have to make in Ms-Project and VBA something like that but in a Formula:

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

I have this code:

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

There are 1 answers

0
Rachel Hettinger On

You were close. The formula you need is this: IIf([Number2]=1,[Duration4],[Duration5]). Note that the function is called Inline If, therefore the abbreviation is IIf, not IFf.