Je proposerai volontiers une fonction personnalisée qui pourra s'utiliser plus facilement...
Function HEIKURA(v)
Dim Niv, Tx, Mt, i%, n%
Application.Volatile
Niv = Array(0, 150, 250, 400, 700, 1000)
Tx = Array(0, 0.003, 0.03, 0.05, 0.07, 0.09)
Mt = Array(0, 150, 100, 150, 300, 300)
If Not IsNumeric(v) Then
HEIKURA = CVErr(xlErrValue): Exit Function
ElseIf v < 0 Or v > 1000 Then
HEIKURA = CVErr(xlErrNA): Exit Function
End If
n = WorksheetFunction.Match(v, Niv, 1) - 1
If n < 5 Then Mt(n + 1) = v - Niv(n)
If n + 1 < 5 Then
For i = n + 2 To 5
Mt(i) = 0
Next i
End If
HEIKURA = WorksheetFunction.SumProduct(Mt, Tx)
End Function
Le code est dans le Module1 du fichier joint.
Elle s'utilise comme les fonctions natives d'Excel. Tu peux poursuivre les tests que j'ai commencé.
La fonction renverra #VALEUR si on ne lui passe pas un nombre, et elle renverra #N/A si le nombre est négatif ou supérieur à 1000.
Cordialement.