+ Reply to Thread
Results 1 to 9 of 9

Extracting numeric values from string

  1. #1
    RJF
    Guest

    Extracting numeric values from string

    My colleague has a problem where he needs to Extract numbers from
    alphanumberic strings. Here is the formula he is using:
    =MID(B7,MATCH(TRUE,ISNUMBER(1*MID(B7,ROW($1:$297),1)),0),COUNT(1*MID(B7,ROW($1:$297),1)))

    It works if alphabetic and numbers are clustered together such as scs987
    It works if alphabetic and numbers are not clustered together such as
    scs987dtg

    Problem: It does not work when numbers are not clustered together such as
    scs987dtg1234

    Any suggestions would be helpful.

    Thank you.

  2. #2
    Peo Sjoblom
    Guest

    RE: Extracting numeric values from string

    You'd need VBA for that

    http://tinyurl.com/53p5b


    Regards,

    Peo Sjoblom

    "RJF" wrote:

    > My colleague has a problem where he needs to Extract numbers from
    > alphanumberic strings. Here is the formula he is using:
    > =MID(B7,MATCH(TRUE,ISNUMBER(1*MID(B7,ROW($1:$297),1)),0),COUNT(1*MID(B7,ROW($1:$297),1)))
    >
    > It works if alphabetic and numbers are clustered together such as scs987
    > It works if alphabetic and numbers are not clustered together such as
    > scs987dtg
    >
    > Problem: It does not work when numbers are not clustered together such as
    > scs987dtg1234
    >
    > Any suggestions would be helpful.
    >
    > Thank you.


  3. #3
    RJF
    Guest

    RE: Extracting numeric values from string

    We actually did find some VBA code that does the trick. It's just that in
    this particular case, we really, really want to use a formula.

    Thank you.

    "Peo Sjoblom" wrote:

    > You'd need VBA for that
    >
    > http://tinyurl.com/53p5b
    >
    >
    > Regards,
    >
    > Peo Sjoblom
    >
    > "RJF" wrote:
    >
    > > My colleague has a problem where he needs to Extract numbers from
    > > alphanumberic strings. Here is the formula he is using:
    > > =MID(B7,MATCH(TRUE,ISNUMBER(1*MID(B7,ROW($1:$297),1)),0),COUNT(1*MID(B7,ROW($1:$297),1)))
    > >
    > > It works if alphabetic and numbers are clustered together such as scs987
    > > It works if alphabetic and numbers are not clustered together such as
    > > scs987dtg
    > >
    > > Problem: It does not work when numbers are not clustered together such as
    > > scs987dtg1234
    > >
    > > Any suggestions would be helpful.
    > >
    > > Thank you.


  4. #4

    Re: Extracting numeric values from string

    RJF wrote...
    ....
    >Problem: It does not work when numbers are not clustered together

    such as
    >scs987dtg1234

    ....

    Do you want the result for this particular string to be 9871234? If so,
    you have two choices: brute force and VBA. The brute force formula
    looks something like

    =IF(ISNUMBER(--MID(A1,1,1)),MID(A1,1,1),"")&IF(ISNUMBER(--MID(A1,2,1)),MID(A1,2,1),"")
    &IF(ISNUMBER(--MID(A1,3,1)),MID(A1,3,1),"")&IF(ISNUMBER(--MID(A1,4,1)),MID(A1,4,1),"")
    &IF(ISNUMBER(--MID(A1,5,1)),MID(A1,5,1),"")&IF(ISNUMBER(--MID(A1,6,1)),MID(A1,6,1),"")
    &IF(ISNUMBER(--MID(A1,7,1)),MID(A1,7,1),"")&IF(ISNUMBER(--MID(A1,8,1)),MID(A1,8,1),"")
    &IF(ISNUMBER(--MID(A1,9,1)),MID(A1,9,1),"")&IF(ISNUMBER(--MID(A1,10,1)),MID(A1,10,1),"")
    &IF(ISNUMBER(--MID(A1,11,1)),MID(A1,11,1),"")&IF(ISNUMBER(--MID(A1,12,1)),MID(A1,12,1),"")
    &IF(ISNUMBER(--MID(A1,13,1)),MID(A1,13,1),"")&IF(ISNUMBER(--MID(A1,14,1)),MID(A1,14,1),"")
    &IF(ISNUMBER(--MID(A1,15,1)),MID(A1,15,1),"")&IF(ISNUMBER(--MID(A1,16,1)),MID(A1,16,1),"")
    &IF(ISNUMBER(--MID(A1,17,1)),MID(A1,17,1),"")&IF(ISNUMBER(--MID(A1,18,1)),MID(A1,18,1),"")
    &IF(ISNUMBER(--MID(A1,19,1)),MID(A1,19,1),"")&IF(ISNUMBER(--MID(A1,20,1)),MID(A1,20,1),"")

    The VBA approach would involve something like

    http://groups-beta.google.com/group/...d252b4201d9d22


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

    Re: Extracting numeric values from string

    Try this formula:

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


    I found it on an old [Solved] thread addressing exactly the same question. I do not even remember if it was on this forum or not. I just know that it works provided you do not need to retain leading zeros and the resulting number is not greater than 15 digits.....it starts rounding after that.

    Hope this one helps.

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Extracting numeric values from string

    FlameRetired, this thread is almost 10 years old, I doubt anyone is still montoring it (I have done the same thing myself, so dont feel too bad lol)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extracting numeric values from string

    Thank you (blush).

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Extracting numeric values from string

    not a problem

  9. #9
    Forum Contributor
    Join Date
    07-10-2012
    Location
    Bangladesh
    MS-Off Ver
    Excel 2007
    Posts
    129

    Re: Extracting numeric values from string

    hats off to FlameRetired

    regards

+ 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