+ Reply to Thread
Results 1 to 3 of 3

Extracting numbers from a text string

  1. #1
    Registered User
    Join Date
    06-11-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    1

    Extracting numbers from a text string

    I have a list of CAS numbers which are in the format xxxxx-xx-x where "x" is a digit from 0 to 9. Example: hexane is 25264-93-1, and ethanol is
    64-17-5. Essentially I want to remove the "-" from the string. Any suggestions how this can be done? I tried apply a macro, but this just copied the first number where the "-" were removed.
    Help appreciated!

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Extracting numbers from a text string

    Hi Cruncher,

    A quick and easy way would be to select your data and use the Find/Replace dialog. Replace the dash/hyphen character with nothing. You'll be left with just numeric strings.

    25264-93-1 will become 25264931.
    64-17-5 will become 64175.

    If you need something different, let us know!

  3. #3
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Extracting numbers from a text string

    A formula like

    =SUBSTITUTE(A1,"-","")

    also works.

    The final digit of a CAS registry number is a check digit which is calculated from those preceding it. As a safeguard, you might want to consider putting in a check for validity when manipulating them.

    See http://en.wikipedia.org/wiki/CAS_registry_number for details.
    Martin

+ 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