I have these two VBA codes, to get the result, I have to put the following excel formula to do the trick : =CCPA(A1)&(MAJUSCULE(A1&MAJUSCULE(RIP(A1)))).
I want to merge the two together in a function named for example : Account, so by just typing =Account(A1), it will give me the result obtained from the formula : =CCPA(A1)&(MAJUSCULE(A1&MAJUSCULE(RIP(A1))))
The codes are :
Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Our guidelines recommend code tags. I have added them for you this time because you are a new member. --6StringJazzer
Function CCPA(X)
Select Case Len(X)
Case 0
c1 = "00799999000000000"
Case 1
c1 = "00799999000000000"
Case 2
c1 = "0079999900000000"
Case 3
c1 = "007999990000000"
Case 4
c1 = "00799999000000"
Case 5
c1 = "0079999900000"
Case 6
c1 = "007999990000"
Case 7
c1 = "00799999000"
Case 8
c1 = "0079999900"
Case 9
c1 = "007999990"
Case 10
c1 = "00799999"
End Select
CCPA = c1
End Function
Public Function RIP(Cle_RIP As String) As String
Cle_RIP = Right(Cle_RIP, 10)
If Cle_RIP = "" Then
Cle_RIP = 0
End If
RIP = Cle_RIP * 100
RIP = RIP - 97 * Int(RIP / 97)
RIP = RIP + 85
If RIP < 97 Then
RIP = RIP + 97
Else
RIP = RIP
End If
RIP = RIP - 97
RIP = 97 - RIP
If RIP < 10 Then
RIP = "0" & RIP
Else
RIP = RIP
End If
End Function
Bookmarks