+ Reply to Thread
Results 1 to 18 of 18

Convert Alphanumeric String To Numbers

  1. #1
    Registered User
    Join Date
    10-29-2021
    Location
    USA
    MS-Off Ver
    O365
    Posts
    51

    Convert Alphanumeric String To Numbers

    Hello everyone. I have an Excel 2016 .xlsx file with just over 37,000 rows, and 20 columns. One of those columns has a unique 4 character code, that I need to turn into a unique numeric-only code (up to 7 digits max). Some examples of this code are below:

    9KDB
    4JJJ
    H1YA
    04HA
    RYUA

    I was thinking if there is a way to convert a letter into a digit using the key below, it should work out to where all 37,000 entries are still unique:

    A - 0
    B - 1
    C - 2
    D - 3
    E - 4
    F - 5
    G - 6
    H - 7
    I - 8
    J - 9
    K - 10
    L - 11
    M - 12
    N - 13
    O - 14
    P - 15
    Q - 16
    R - 17
    S - 18
    T - 19
    U - 20
    V - 21
    W - 22
    X - 23
    Y - 24
    Z - 25

    I would truly appreciate any help with this. Thank you!
    Last edited by mightymo77; 10-30-2021 at 07:30 AM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,888

    Re: Convert Alphanumeric String To Numbers

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by JohnTopley; 10-29-2021 at 04:50 PM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Convert Alphanumeric String To Numbers

    Paste this code into a macro module.

    Then the formula =ReCode(a1) will translate the number in A1 for you.


    Please Login or Register  to view this content.
    Attached Files Attached Files
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,488

    Re: Convert Alphanumeric String To Numbers

    Bit ugly, but
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,744

    Re: Convert Alphanumeric String To Numbers

    Hello mightymo77. Welcome to the forum.

    Try this and see if it does the job. Your sample outputs as no more than 6 digits. See how it performs with larger "numbers".

    Treat those as base 36 numbers. Covert to decimals with source data in column A this in B1
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Then to convert back this in C1
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    A
    B
    C
    1
    0KCB
    26363
    0KCB
    2
    7XJK
    370064
    7XJK
    3
    LB8A
    994330
    LB8A
    4
    9BGA
    434746
    9BGA
    5
    D9EA
    618706
    D9EA
    Dave

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,488

    Re: Convert Alphanumeric String To Numbers

    Based on the VBA UDF from mehmetcik

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,488

    Re: Convert Alphanumeric String To Numbers

    @FR: ooohhhhh ... I like that! Why not combine the two?
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    That is so neat.

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,744

    Re: Convert Alphanumeric String To Numbers

    Thank you, and yes combining the two a cool idea. I learned about the DECIMAL base 36 trick from Lori over at XOR LX's site. She used it to convert A1 cell addresses to R1C1.

  9. #9
    Registered User
    Join Date
    10-29-2021
    Location
    USA
    MS-Off Ver
    O365
    Posts
    51

    Re: Convert Alphanumeric String To Numbers

    Wow thank you guys very much! I really do appreciate it. Which one of these should I use, I see a bunch of different options. Sorry, once I learn I will have it :D
    Last edited by mightymo77; 10-29-2021 at 06:50 PM.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,488

    Re: Convert Alphanumeric String To Numbers

    You're welcome.

    Personally, I’d go with post #7 … the combined version of FlameRetired's solution. You should test all of the solutions with a wider range of codes to see how they all cope.

    I wouldn't go with mehmetcik's UDF (nothing personal ) unless you are using VBA anyway.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  11. #11
    Registered User
    Join Date
    10-29-2021
    Location
    USA
    MS-Off Ver
    O365
    Posts
    51

    Re: Convert Alphanumeric String To Numbers

    I tried FlameRetired's code in post #5 and it works great. I then tried the =BASE(DECIMAL(A2,36),36,LEN(A2)) code but that is producing alphanumeric codes. It needs to be only numeric (up to 7 digits long). Unless I did something wrong?

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,488

    Re: Convert Alphanumeric String To Numbers

    My bad. I was thinking it was a two stage process. But it's not. One is converting it (to something). The other is converting it back. By combining the formulae, it just gives you back what you started with … which is a good sign maybe but not what you need.

    That said, FR's solution doesn't convert by the rules you outlined. You ok with that?

  13. #13
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,888

    Re: Convert Alphanumeric String To Numbers

    Please Login or Register  to view this content.
    Inserts formula into column C

  14. #14
    Registered User
    Join Date
    10-29-2021
    Location
    USA
    MS-Off Ver
    O365
    Posts
    51

    Re: Convert Alphanumeric String To Numbers

    Thank you everyone who assisted with this. After viewing/learning it seems pretty simple. You guys rock!

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,888

    Re: Convert Alphanumeric String To Numbers

    VBA to do Base 36 calculation:
    Please Login or Register  to view this content.
    Results in column D
    Attached Files Attached Files

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    91,030

    Re: Convert Alphanumeric String To Numbers

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  17. #17
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,744

    Re: Convert Alphanumeric String To Numbers

    Administrative Note:

    Welcome to the forum.

    Unfortunately, it has come to our attention you have violated Rule #8 of our Forum RULES:

    Don't private message, visitor message or email Excel (or Access, Word, etc.) questions to moderators or other members.

    All questions and answers will benefit other posters like yourself when discussed in public threads. The point of having a public forum is to share solutions to common (and sometimes uncommon) problems with all members.

    Breaking this rule is considered harassment by most of our contributors and thus cannot be tolerated. Repeat offense could lead to a permanent ban, so do take this caution to heart.

    Post your question in a public thread and our many contributors will come to your assistance, especially if the title is accurate (see Rule #1) and you include a sample desensitized workbook that makes it easy for others to try and help.

    I've responded to your PM with this in mind.

    Please keep related questions posted in this thread.
    Last edited by FlameRetired; 10-31-2021 at 01:29 PM.

  18. #18
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,744

    Re: Convert Alphanumeric String To Numbers

    And thank you for the feedback and added rep.

+ 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. [SOLVED] How can I convert an alphanumeric string to a number?
    By computertutor in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 02-20-2014, 03:27 PM
  2. [SOLVED] Remove numbers from alphanumeric string. No standard format to the string.
    By ricunger in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-20-2012, 01:43 PM
  3. [SOLVED] Auto convert an alphanumeric string (CIS9638S) to numbers only?
    By SDesmond in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-07-2005, 12:05 AM
  4. Auto convert an alphanumeric string (CIS9638S) to numbers only?
    By SDesmond in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-07-2005, 12:05 AM
  5. [SOLVED] Auto convert an alphanumeric string (CIS9638S) to numbers only?
    By Gary L Brown in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2005, 11:05 PM
  6. RE: Auto convert an alphanumeric string (CIS9638S) to numbers only?
    By Gary L Brown in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 PM
  7. [SOLVED] RE: Auto convert an alphanumeric string (CIS9638S) to numbers only?
    By B. R.Ramachandran in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 PM
  8. [SOLVED] Auto convert an alphanumeric string (CIS9638S) to numbers only?
    By SDesmond in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 09:05 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