I want to Calculate the Key Of a current bank Account (CCP Algeria); using a VBA in excel; I’ve Managed to do it in excel using the following formula:
=TEXTE(SI(((MOD(97-((89*(7)+15*(99999)+3*E6));97))+30)>97;(MOD(97-((89*(7)+15*(99999)+3*E6));97))+30-97;(MOD(97-((89*(7)+15*(99999)+3*E6));97))+30);"00")
But in VBA, when the Account is eight digits, for example ‘24378883’ I got an error message. Also for an account: (1593132) that the key should be ‘97’ , is gives me ‘00’.
The Code in VBA I used is:
Public Function rip_ccp(y)
x1 = y * 100#
X = x1 Mod 97
' MOD CCP MOD 99999000000000000= 85=w
w = 85
If (X + w) > 97 Then c = (X + w) - 97 Else c = (X + w)
d = 97 - c
If d < 10 Then k = "0" & d Else k = d
rip_ccp = k
End Function