+ Reply to Thread
Results 1 to 12 of 12

Want to split alpha numerals and then compare and provide difference using macro

Hybrid View

  1. #1
    Registered User
    Join Date
    08-21-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2013
    Posts
    82

    Want to split alpha numerals and then compare and provide difference using macro

    Hi excel gurus,

    We have process were we receive 2 set of datas one just numerals and another one the same data but with alpha numerals we want to split the alpha numerals and compare the balances.

    The columns will be like below

    Currency. deal. balance
    THB THB113456 100000

    Kindly help us with Macro to find the difference

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2507 Win 11
    Posts
    24,922

    Re: Want to split alpha numerals and then compare and provide difference using macro

    Are the alphas always three characters in length?
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Valued Forum Contributor
    Join Date
    04-12-2012
    Location
    India
    MS-Off Ver
    Excel 2007, 2010, 2013, 2016, 2019, Office 365, Google Spreadhsheet
    Posts
    640

    Re: Want to split alpha numerals and then compare and provide difference using macro

    Hi Aravind,

    Use following functions to separate your text and numbers from a cell.

    To separate text - "=LEFT(A2,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"))-1)"
    To separate number - "=RIGHT(A2,LEN(A2)-MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"))+1)"

    Place your formula anywhere but the value should be in A2 to test this function.

    Let me know if it works for you.
    Thanks,
    Anil Dhawan


    Click *Add Reputation to say "Thanks" and don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved) if you are satisfied.

    Don't stop when you are tired. STOP when you are done!

  4. #4
    Registered User
    Join Date
    08-21-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2013
    Posts
    82

    Re: Want to split alpha numerals and then compare and provide difference using macro

    Is it possible to do it through a macro

  5. #5
    Valued Forum Contributor
    Join Date
    04-12-2012
    Location
    India
    MS-Off Ver
    Excel 2007, 2010, 2013, 2016, 2019, Office 365, Google Spreadhsheet
    Posts
    640

    Re: Want to split alpha numerals and then compare and provide difference using macro

    Quote Originally Posted by aravindkm View Post
    Is it possible to do it through a macro
    Hi Aravind,

    Yups, there is always a way to do anything in this world. However, I m not good in Macros and dont want to give you any bad example. :P

    Our other experts may help you in this.

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,447

    Re: Want to split alpha numerals and then compare and provide difference using macro

    Hi Aravind,

    See if this code in a User Defined Function (UDF) does what you need.
    Function DiffWithAlpha(strInput As String)
        Dim Parts As Variant
        
        Parts = Split(strInput, " ")
        On Error Resume Next
            Do Until CDbl(Parts(1)) > 0
                Parts(1) = Mid(Parts(1), 2)
            Loop
        On Error GoTo 0
        
        DiffWithAlpha = Parts(1) - Parts(2)
    End Function
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  7. #7
    Registered User
    Join Date
    08-21-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2013
    Posts
    82

    Re: Want to split alpha numerals and then compare and provide difference using macro

    Thanks for your code

    However I have 2 worksheets where one sheet has the data without alpha numerals and other sheet has data with alpha numerals with the same balances I want to have split the alpha numerals in the second sheet and get the difference in the balances if any between 2 sheets

  8. #8
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Want to split alpha numerals and then compare and provide difference using macro

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  9. #9
    Registered User
    Join Date
    08-21-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2013
    Posts
    82

    Re: Want to split alpha numerals and then compare and provide difference using macro

    Hi,

    Please find enclosed worksheet with macro for your reference.

    Where the Macro is working fine however when the deals were in two different rows the difference is coming wrongly.

    Kindly help in fixing the macro to help me save time.

    Thanks

    Aravind
    Attached Files Attached Files

  10. #10
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Want to split alpha numerals and then compare and provide difference using macro

    Try this to see if you get the correct output....

    Sub Test()
    Dim lr As Long
    Dim rng As Range
    lr = Cells(Rows.Count, 3).End(xlUp).Row
    Set rng = Range("E2:E" & lr)
    rng.Formula = "=VLOOKUP(""*""&C2&""*"",BB!$C$2:$D$100,2,0)-D2"
    End Sub
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    08-21-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2013
    Posts
    82

    Re: Want to split alpha numerals and then compare and provide difference using macro

    Hi,

    Thanks for the code.

    Since the row is too high use more than 1 lakh rows this macro is taking too much time.
    Could you please help me some other way.

    Please

    Thanks

  12. #12
    Registered User
    Join Date
    10-07-2012
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Want to split alpha numerals and then compare and provide difference using macro

    Hi,
    This formula works fine if the cells are in a format such as BA123. Can you please help me with a formula that will do the same for my data? See Example:
    iNITIAL Data Numeric Results Needed Alpha Results Needed
    79 79
    79A 79 A
    234 234
    234A 234 A
    234B 234 B
    234C 234 C

    Thank You
    Sharon

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Want Split Alpha Numerials and then compare the balances from 2 sheets using macro
    By aravindkm in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 04-06-2015, 11:51 PM
  2. [SOLVED] Calculation to Provide Difference Between Two Times Less a Break
    By ltradey in forum Excel General
    Replies: 8
    Last Post: 07-10-2014, 04:11 AM
  3. Macro to Split by date, do a few easy calcualtion, and provide a link page :)
    By Tmc2159 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-12-2013, 10:13 AM
  4. [SOLVED] Macro for compare and insert the difference
    By Daniel Chang in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-09-2013, 03:55 AM
  5. Compare 2 rows and (if they match), provide difference between 2 dates
    By PastramiDave in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-12-2012, 02:43 PM

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