+ Reply to Thread
Results 1 to 6 of 6

Formula to extract number from a string

  1. #1
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    Formula to extract number from a string

    I am looking for a formula that can find a specific word then display the value associated with that word.

    Attached is a speard sheet that has a Cell B4 that has a string of data that I would like to extract the number value associated with the words "Ratio1", "Ratio2"... and on then find the number that is to the right of that word "Ratio1", "Ratio2"... and show the value.

    This is cell B4
    Please Login or Register  to view this content.
    And I want a formula that will result in the number to the right of the words Ratio1, Ratio2...

    The desired results are in cells D4:D9

    D4 would have this
    Please Login or Register  to view this content.
    D5 would have this:
    Please Login or Register  to view this content.
    The word "Ratio1" can be of any length and can be different the length of "Ratio2". Also the number can be of any length.

    I hope this one is simple!
    Attached Files Attached Files
    Last edited by Bobbbo; 03-28-2017 at 12:23 PM. Reason: question solved

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: Formula to extract number from a string

    Try

    in C4

    =RIGHT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($B4,"""",""),":","="),"}",""),LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($B4,"""",""),":","="),"}",""))-14)

    Assumes [ABC_CacheA] { is "constant"

    in D4

    =TRIM(MID(SUBSTITUTE($C$4,",",REPT(" ",99)),(ROWS($1:1)-1)*99+1,99))

    Copy down

  3. #3
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    Re: Formula to extract number from a string

    Quote Originally Posted by JohnTopley View Post
    Try

    in C4

    =RIGHT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($B4,"""",""),":","="),"}",""),LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($B4,"""",""),":","="),"}",""))-14)

    Assumes [ABC_CacheA] { is "constant"

    in D4

    =TRIM(MID(SUBSTITUTE($C$4,",",REPT(" ",99)),(ROWS($1:1)-1)*99+1,99))

    Copy down
    Thanks John, It works great. The only issues is my actual data string has 11 Ratios "Ratio1" through "Ratio11" How would I change your formula for 11 Ratios rather than the 5 I showed in my example?

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: Formula to extract number from a string

    Try

    in D4

    =TRIM(MID(SUBSTITUTE($C$4,",",REPT(" ",250)),(ROWS($1:1)-1)*250+1,250))

    Copy down

  5. #5
    Forum Contributor
    Join Date
    04-05-2010
    Location
    Lakewood, IL
    MS-Off Ver
    Excel 2016
    Posts
    384

    Re: Formula to extract number from a string

    Quote Originally Posted by JohnTopley View Post
    Try

    in D4

    =TRIM(MID(SUBSTITUTE($C$4,",",REPT(" ",250)),(ROWS($1:1)-1)*250+1,250))

    Copy down
    Thanks John, I got it to work but needed to change the 250 number to 500 and 1,250 to 1,500.!

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: Formula to extract number from a string

    See attached.

    =TRIM(MID(SUBSTITUTE($C$4,",",REPT(" ",300)),(ROWS($1:1)-1)*300+1,300))
    Attached Files Attached Files
    Last edited by JohnTopley; 03-28-2017 at 04:39 AM.

+ 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. Extract number from string
    By tieyanna in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-21-2016, 09:50 AM
  2. Need Formula to extract number from text string
    By tuongtu3 in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 03-28-2015, 06:01 PM
  3. Mid and Mod to extract a number from string
    By jonboy6257 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-22-2013, 02:12 PM
  4. [SOLVED] How to Extract A Number from String if Text within the String Equals XYZ
    By tyrsfury in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-15-2012, 03:30 PM
  5. [SOLVED] Extract a mainly numeric string (ISSN number) from an arbitrary string
    By Buzzed Aldrin in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 07-04-2012, 01:49 PM
  6. Extract Number from String Help
    By kobe4ever8 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-31-2011, 02:25 PM
  7. Extract number out of a string
    By mkvassh in forum Excel General
    Replies: 4
    Last Post: 04-07-2010, 05:25 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