Results 1 to 6 of 6

Merge two VBA codes in one

Threaded View

  1. #1
    Registered User
    Join Date
    08-13-2023
    Location
    Algeria
    MS-Off Ver
    2007
    Posts
    2

    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 :

    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
    Last edited by 6StringJazzer; 08-13-2023 at 08:22 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Merge two codes
    By juriemagic in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2019, 07:06 AM
  2. How to Merge Two Worksheet_Change Codes
    By merveileuse in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-09-2019, 04:56 AM
  3. merge vba codes together
    By pejabe in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-11-2017, 08:58 AM
  4. Replies: 5
    Last Post: 01-27-2014, 12:20 PM
  5. [SOLVED] Merge 2 vba codes together
    By abjac in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-13-2013, 03:59 AM
  6. Merge codes
    By tofimoon4 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-18-2011, 06:22 AM
  7. merge with Word How can I get excel to mail merge zip codes plus 4 correctly?
    By Kathy at Sauder Feeds in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-30-2005, 07:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1