Fonction RIST excel avec macro

Bonjour,
Je doit faire une macro pour avoir le montant d'une ristourne mais cela ne fonctionne.
Je vous met ci dessous mon algo.
Merci d'avance

Function Rist(CA As Single, TX01 As Single, TX02 As Single, TX03 As Single, SEUIL01 As Single, SEUIL02 As Single, SEUIL03 As Single) As Single
Dim Ristourne As Single

If CA > SEUIL03 Then
Ristourne = (TX03 * (CA - SEUIL03)) + (TX02 * (SEUIL03 - SEUIL02)) + (TX01 * (SEUIL02 - SEUIL01))
Else
If CA > SEUIL02 Then
Ristourne = (TX02 * (CA - SEUIL2)) + (TX01 * (SEUIL02 - SEUIL01))
Else
If CA > SEUIL01 Then
Ristourne = TX01 * (CA - SEUIL01)
Else: Ristourne = 0
End If
End If
End If
Rist = Ristourne

End Function

1 réponse

  • Votes
  • Date
  • Date décroissante
  1. Bonjour,

    Rajoute devant ton code :
    Option Explicit

    Compile, et tu verras que tu as une variable non définie !

    Cordialement