Below is the function I defined. It is supposed to calculate the amount of payment terms between two dates (rounded up) and do this according to a dropdown menu that gives users the option to select monthly, quarterly or yearly payments. Functions first argument is the result of this dropdown, the second argument is the first date and the third argument is the last date or end date for this specific payment plan.
The error message I'm getting is that the arguments aren't optional. The weird thing is that in excel im filling al the arguments (with cells in the form of
"Termijnbereken ing(C4;D4;F4)"
But it still gives me the error. Below my code:
The error message I'm getting is that the arguments aren't optional. The weird thing is that in excel im filling al the arguments (with cells in the form of
"Termijnbereken ing(C4;D4;F4)"
But it still gives me the error. Below my code:
Code:
Function Termijnberekening(Termijn As Variant, Ingangsdatum As Date, Einddatum As Date) As Integer
If Termijn = "Maand" Then
Termijnberekening = (Year(Einddatum) - Year(Ingangsdatum)) * 12 + Month(Einddatum) - Month(Ingangsdatum)
ElseIf Termijn = "Kwartaal" Then
Termijnberekening = (Year(Einddatum) - Year(Ingangsdatum)) * 4 + WorksheetFunction.RoundUp((Month(Einddatum) - Month(Ingangsdatum)) / 3)
ElseIf Termijn = "Jaar" Then
Termijnberekening = (Year(Einddatum) - Year(Ingangsdatum))
Else
Termijnberekening = "Kies Termijn Type"
End Function
Comment