+ Reply to Thread
Results 1 to 9 of 9

Extract numbers before a string

  1. #1
    Forum Contributor
    Join Date
    03-18-2010
    Location
    FL
    MS-Off Ver
    Excel 2016
    Posts
    147

    Extract numbers before a string

    Hi, please help extracting only the numbers before string "all", please see an example attached. Need a formula to get the results as in column B. Thank you
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Extract numbers before a string

    If the data is as you showed.

    =MID(A3,SEARCH("all",A3,1)-4,3)
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,740

    Re: Extract numbers before a string

    will the ALL always be at the end of the text string
    and the numbers can they be any length ?

    and so the number will always be at the 2nd space from the end of the string
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  4. #4
    Forum Contributor
    Join Date
    03-18-2010
    Location
    FL
    MS-Off Ver
    Excel 2016
    Posts
    147

    Re: Extract numbers before a string

    Thank you! There is an issue when the numbers is only 1 digits, see file please.
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Extract numbers before a string

    Please try

    for row 2
    =VALUE(TRIM(RIGHT(SUBSTITUTE(TRIM(SUBSTITUTE(A2,"all",""))," ",REPT(" ",LEN(TRIM(SUBSTITUTE(A2,"all",""))))),LEN(TRIM(SUBSTITUTE(A2,"all",""))))))

    note : all data must ended with 'all'

    Regards.

  6. #6
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,910

    Re: Extract numbers before a string

    Or try this:

    =--RIGHT(SUBSTITUTE(LEFT(A2,FIND(" all",A2)-1)," ",REPT(" ",100)),100)

  7. #7
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Extract numbers before a string

    Please try

    =-LOOKUP(0,-RIGHT(LEFT(A2,FIND("all",A2)-2),{1,2,3,4,5}))
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Extract numbers before a string

    Another option:

    =LET(a,FIND(" all",A2),b,LEFT(A2,a-1),c,MAX(IF(MID(b,SEQUENCE(LEN(b)),1)=" ",SEQUENCE(LEN(b)),0)),MID(A2,c+1,a-c)+0)

  9. #9
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Extract numbers before a string

    Try this. In C2

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

+ 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 numbers on the left in a string that also contains numbers on the right
    By Sybille in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 05-27-2022, 10:01 AM
  2. Extract all numbers from string, returning numbers to individual cells
    By LJBOS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-27-2020, 08:46 AM
  3. Extract Numbers from String
    By mattneil41 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-17-2017, 05:48 AM
  4. Extract numbers from a string
    By Nighteg in forum Excel General
    Replies: 5
    Last Post: 11-03-2016, 09:35 AM
  5. extract numbers & / only from a string
    By Sean Thomas in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-04-2016, 06:38 AM
  6. Extract Numbers from a string
    By dugong in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-21-2008, 06:21 AM
  7. [SOLVED] Extract numbers from a string ?
    By Jello in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-03-2005, 07:06 PM

Tags for this Thread

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