+ Reply to Thread
Results 1 to 7 of 7

Extracting A Number From A String Of Text

  1. #1
    Registered User
    Join Date
    08-28-2012
    Location
    Sheffield, UK
    MS-Off Ver
    Excel 2010
    Posts
    29

    Extracting A Number From A String Of Text

    Hi

    I have been trying to find a formula that would extract a number from a string of text.

    The cell in the Excel spreadsheet is formatted as below and I would just like to extract the number between the :'s.

    user:12345678:supportuser
    system:87654321:systemuser

    Hoping someone can help

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Extracting A Number From A String Of Text

    Will the number string ever start with leading zeros?

    012345678
    000456789

    EDIT: Will the number string ALWAYS be the same length? Your samples are both 8 digits long.
    Last edited by Tony Valko; 10-15-2013 at 02:07 PM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Extracting A Number From A String Of Text

    Try

    =MID(A1,FIND(":",A1)+1,FIND(":",A1,FIND(":",A1)+1)-FIND(":",A1)-1)*1
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  4. #4
    Registered User
    Join Date
    08-28-2012
    Location
    Sheffield, UK
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: Extracting A Number From A String Of Text

    Quote Originally Posted by Tony Valko View Post
    Will the number string ever start with leading zeros?

    012345678
    000456789

    EDIT: Will the number string ALWAYS be the same length? Your samples are both 8 digits long.
    Some numbers will start with a leading zero and may sometimes be 9 digits

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Extracting A Number From A String Of Text

    Try this...

    Data Range
    A
    B
    2
    user:12345678:supportuser
    12345678
    3
    system:087654321:systemuser
    087654321

    This formula entered in B2 and copied down:

    =TRIM(MID(SUBSTITUTE(A2,":",REPT(" ",100)),100,100))

  6. #6
    Registered User
    Join Date
    08-28-2012
    Location
    Sheffield, UK
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: Extracting A Number From A String Of Text

    Quote Originally Posted by Tony Valko View Post
    Try this...

    Data Range
    A
    B
    2
    user:12345678:supportuser
    12345678
    3
    system:087654321:systemuser
    087654321

    This formula entered in B2 and copied down:

    =TRIM(MID(SUBSTITUTE(A2,":",REPT(" ",100)),100,100))
    That works great, thanks so much

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Extracting A Number From A String Of Text

    You're welcome. Thanks for the feedback!

+ 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. Extracting numbers and text from inconsistent text/number formatted string
    By Brandivil in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-25-2013, 01:46 PM
  2. Extracting a number (part of a series of numbers) from a text string
    By dannyjoer in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-09-2012, 10:17 AM
  3. Replies: 6
    Last Post: 07-29-2008, 03:23 PM
  4. Extracting numbers from a combined text & number string
    By astrikor in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-25-2007, 08:45 AM
  5. [SOLVED] Extracting a number in a text string
    By Pogo in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-17-2006, 01:45 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