Bonjour,
J'essaie de créer une fonction excel dans laquelle je dois manipuler des dates. Voici ma fonction:
Function DepreciationBV(PrixStock, DernEntree, CMJ, Stock, PrevCommande, Optional DateDepreciation)
Application.Volatile True
If DateDepreciation = "" Then DateDepreciation = Date
If Stock = 0 Or DernEntree > DateSerial(Year(DateDepreciation), Month(DateDepreciation) - 3, Day(DateDepreciation)) Then
DepreciationBV = 0
ElseIf PrevCommande >= Stock Or (CMJ * 20) > Stock Then
DepreciationBV = 0
ElseIf DernEntree < DateSerial(Year(DateDepreciation), Month(DateDepreciation) - 6, Day(DateDepreciation)) Then
DepreciationBV = (Stock - PrevCommande) * PrixStock
Else
DepreciationBV = (Stock - PrevCommande) * PrixStock * 0.5
End If
End Function
Le valeur de la cellule retournée est #VALEUR!, en approfondissant les lignes de code qui posent posent problèmes sont celle où il y a DateDepreciation, Date et DateSerial.
Merci de m'indiquer où se trouve le ou les problèmes.
Cordialement
J'essaie de créer une fonction excel dans laquelle je dois manipuler des dates. Voici ma fonction:
Function DepreciationBV(PrixStock, DernEntree, CMJ, Stock, PrevCommande, Optional DateDepreciation)
Application.Volatile True
If DateDepreciation = "" Then DateDepreciation = Date
If Stock = 0 Or DernEntree > DateSerial(Year(DateDepreciation), Month(DateDepreciation) - 3, Day(DateDepreciation)) Then
DepreciationBV = 0
ElseIf PrevCommande >= Stock Or (CMJ * 20) > Stock Then
DepreciationBV = 0
ElseIf DernEntree < DateSerial(Year(DateDepreciation), Month(DateDepreciation) - 6, Day(DateDepreciation)) Then
DepreciationBV = (Stock - PrevCommande) * PrixStock
Else
DepreciationBV = (Stock - PrevCommande) * PrixStock * 0.5
End If
End Function
Le valeur de la cellule retournée est #VALEUR!, en approfondissant les lignes de code qui posent posent problèmes sont celle où il y a DateDepreciation, Date et DateSerial.
Merci de m'indiquer où se trouve le ou les problèmes.
Cordialement