Petit oubli....
Function CalculRib(ByVal CodeBanque, ByVal CodeAgence, ByVal Numero)
Dim D As Double, E As Double, F As Double, G As Double
Dim H As Double, I As Double, Boucle As Long, Occ As Long
Const Lettres = 'AAJBKSCLTDMUENVFOWGPXHQYIRZ'
Numero = UCase(Numero)
For Boucle = 1 To Len(Numero)
If InStr(1, Lettres & '0123456789', Mid(Numero, Boucle, 1)) = 0 Then
'renvoie une erreur #VALEUR si un caractère invalide est détecté
CalculRib = CVErr(xlErrValue)
Exit Function
End If
Occ = InStr(1, Lettres, Mid(Numero, Boucle, 1), vbTextCompare)
If Occ > 0 Then
If Occ Mod 3 = 0 Then Occ = Occ - 1
Numero = Left(Numero, Boucle - 1) & 1 + (Occ \\ 3) & Mid(Numero, Boucle + 1)
End If
Next Boucle
If Numero = '' Then Numero = 0
Numero = CDbl(Numero)
D = CodeBanque * 8
CodeBanque = Int(D / 97)
CodeBanque = D - (CodeBanque * 97)
E = CodeAgence * 15
CodeAgence = Int(E / 97)
CodeAgence = 97 - (E - (CodeAgence * 97))
F = Numero * 3
Numero = Int(F / 97)
Numero = 97 - (F - (Numero * 97))
G = CodeBanque + CodeAgence + Numero
H = Int(G / 97)
I = G - (H * 97)
If I = 0 Then I = 97
CalculRib = I
End Function