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
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.