Results 1 to 7 of 7

Thread: how to merge two VBA codes in one?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Post how to merge two VBA codes in one?

    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 :

    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
    Last edited by Aussiebear; 08-13-2023 at 03:17 AM. Reason: Added code tags to supplied code

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •