+ Reply to Thread
Results 1 to 8 of 8

How do I extract a number from an alphanumeric string?

  1. #1
    Registered User
    Join Date
    04-11-2012
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    3

    How do I extract a number from an alphanumeric string?

    I'm trying to pull numbers from alphanumeric strings so I can do calculations. For example:

    If I had the following strings below, how would I pull out 40, 100, and 150 to a new column and convert these to a number so I can do calculations?

    tune-up/pctu40-b
    subscription1yr1p/100-b
    subcription1yr3p/150-b

    I'm using Excel 2007. Thanks for your help.

    -P

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How do I extract a number from an alphanumeric string?

    Hi,

    One way, as an array formula entered with Ctrl-Shift-Enter

    =1*MID(RIGHT(A1,LEN(A1)-FIND("/",A1)),MATCH(1,--ISNUMBER(--MID(RIGHT(A1,LEN(A1)-FIND("/",A1)),ROW($B$1:$B$100),1)),0),SUM(--ISNUMBER(--MID(RIGHT(A1,LEN(A1)-FIND("/",A1)),ROW($B$1:$B$100),1))))
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: How do I extract a number from an alphanumeric string?

    Assuming the number is always followed by 2 characters at the end of the text, as per your examples, then try this formula in B2 to extract the number (up to 5 digits) from A2

    =LOOKUP(10^5,RIGHT(LEFT(RIGHT(A2,7),5),{1,2,3,4,5})+0)
    Audere est facere

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How do I extract a number from an alphanumeric string?

    Ah, well spotted ddl.

    I hadn't seen that common factor.

    Regards

  5. #5
    Registered User
    Join Date
    04-11-2012
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How do I extract a number from an alphanumeric string?

    Thanks for the help, but I must be doing something wrong. Would it be possible for me to email one of you a real spreadsheet with real data? Thanks again for the help.

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: How do I extract a number from an alphanumeric string?

    Can you gives some examples where the suggested formulas don't work? I tested my suggestion on your examples and they all return the correct values I believe - does the formula work for them?

  7. #7
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: How do I extract a number from an alphanumeric string?

    Or this if you always end with -b:

    =LOOKUP(99^99,--RIGHT(SUBSTITUTE(A1,"-b",""),ROW($A$1:$A$10)))

  8. #8
    Registered User
    Join Date
    04-11-2012
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How do I extract a number from an alphanumeric string?

    This is what I get when I use your formula.excel_example.png

+ 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