+ Reply to Thread
Results 1 to 5 of 5

How to extract numbers from a string

Hybrid View

Ian99099 How to extract numbers from a... 02-28-2015, 09:26 AM
Pepe Le Mokko Re: How to extract numbers... 02-28-2015, 09:42 AM
AlKey Re: How to extract numbers... 02-28-2015, 09:49 AM
vlady Re: How to extract numbers... 02-28-2015, 10:02 AM
newdoverman Re: How to extract numbers... 02-28-2015, 11:22 AM
  1. #1
    Registered User
    Join Date
    11-29-2013
    Location
    UK
    MS-Off Ver
    Office 365 subscription
    Posts
    58

    How to extract numbers from a string

    Is anyone able to tell me how to extract the last 2 No. 5 or 6 digit numbers from strings such as these please?

    I need to convert

    Cell B1 = Basingstoke,51.26654,-1.092396,463418,152322
    Cell B2 = Bournemouth East,50.719164,-1.880769,408513,91066

    to

    cell C1 = 463418

    cell D1 =152322

    cell C2 = 408513

    cell D2 = 91066

    Thanks in anticipation

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,616

    Re: How to extract numbers from a string

    Try Data - text to columns - Use comma as delimiter. In the last window of the wizard choose NOT to import the 3 first columns ( or delete them manually if you prefer)

  3. #3
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: How to extract numbers from a string

    Or use formula

    in C1 and pull formula to the right and down until you see blanks

    =TRIM(MID(SUBSTITUTE($B1,",",REPT(" ",125)),125*(LEN($B1)-LEN(SUBSTITUTE($B1,",",""))+COLUMNS($A:A)-2),125))

    Updated formula to insure there will be always extracted only the last two groups of digits in case the size of the string changes.


    Row\Col
    B
    C
    D
    1
    Basingstoke,51.26654,-1.092396,463418,152322 463418 152322
    2
    Bournemouth East,50.719164,-1.880769,408513,91066 408513 91066
    3
    Bournemouth East,50.719164,-1.880769,408513,91067,555555,666666 555555 666666
    Last edited by AlKey; 02-28-2015 at 01:19 PM.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  4. #4
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: How to extract numbers from a string

    try also

    in c1 drag down
    Formula: copy to clipboard
    =TRIM(RIGHT(SUBSTITUTE(B1,",",REPT(" ",LEN(B1))),LEN(B1)))

    and in d1
    Formula: copy to clipboard
    =TRIM(LEFT(RIGHT(SUBSTITUTE(B1,",",REPT(" ",100)),200),100))
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  5. #5
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How to extract numbers from a string

    In C1 enter and fill down:
    Formula: copy to clipboard
    =IFERROR(--TRIM(LEFT(RIGHT(SUBSTITUTE(B1,",",REPT(" ",LEN(B1))),LEN(B1)*2),LEN(B1))),"")


    In D1 enter and fill down:
    Formula: copy to clipboard
    =IFERROR(--TRIM(RIGHT(SUBSTITUTE(B1,",",REPT(" ",LEN(B1))),LEN(B1))),"")


    Result is real numbers and not text numbers:
    B
    C
    D
    1
    Basingstoke,51.26654,-1.092396,463418,152322
    463418
    152322
    2
    Bournemouth East,50.719164,-1.880769,408513,91066
    408513
    91066
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

+ 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. [SOLVED] Extract string into numbers (Solved by Benishiryo)
    By hoandt in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-21-2012, 01:38 PM
  2. Extract numbers from string
    By grey_hair in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-05-2011, 01:54 AM
  3. Extract last 4 numbers from string
    By DarkBeer in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-15-2010, 11:16 AM
  4. Extract numbers from a string
    By andyiain in forum Excel General
    Replies: 6
    Last Post: 09-06-2006, 07:10 AM
  5. [SOLVED] Extract numbers from a string ?
    By Jello in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-03-2005, 07:06 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