+ Reply to Thread
Results 1 to 7 of 7

Extract TEXT from alphanumeric cell

  1. #1
    Registered User
    Join Date
    10-23-2009
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    1

    Extract TEXT from alphanumeric cell

    Hi. I've got a cell with codes, such as:
    21ML,
    43GKP,
    etc.

    I want these to look like :
    ML21,
    GKP43,
    i.e. swap the numbers with the letters but keeping the order of the characters.


    I can extract the number with :
    Please Login or Register  to view this content.
    This code is from Microsoft and works fine. But now I need something to get the text from the code, to then concatenate it with the number.

    Any ideas?

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Extract TEXT from alphanumeric cell

    If you're open to adding a new function to your workbook, this can do it simply for you.
    Please Login or Register  to view this content.
    ==========
    How to install the User Defined Function:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save your sheet

    The function is installed and ready to use.
    ============

    The new function is used like so...if the text string is in cell A1, this formula will convert the string the TxtNum format:
    =SWAP(A1)

    The new function has an optional second parameter, so if you ever want to switch the result and get NumTxt, use this instead:
    =SWAP(A1, "n")
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Extract TEXT from alphanumeric cell

    A VBA approach:
    Please Login or Register  to view this content.
    EDIT: went away and JB has now catered for your needs.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Extract TEXT from alphanumeric cell

    In formula terms, assuming strings in A1, A2 etc...

    Please Login or Register  to view this content.
    of course if the numbers are always 2 digits in length......

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Extract TEXT from alphanumeric cell

    How about this:
    Please Login or Register  to view this content.
    EDITED to include this shorter alternative:
    Please Login or Register  to view this content.
    Last EDIT (hopefully)
    If the cell may contain leading zeros:
    Please Login or Register  to view this content.
    Is that something you can work with?
    Last edited by Ron Coderre; 10-23-2009 at 01:31 PM.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Extract TEXT from alphanumeric cell

    Quote Originally Posted by Ron Coderre View Post
    EDITED to include this shorter alternative:
    Please Login or Register  to view this content.
    Very slick Mr C - that is why you are an MVP !
    (I wish I could think like that!)

  7. #7
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Extract TEXT from alphanumeric cell

    Thank you, my friend.
    Sometimes...for the briefest of moments...I feel like I know what I'm doing.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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