+ Reply to Thread
Results 1 to 16 of 16

Need Formula to extract number from text string

  1. #1
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    810

    Need Formula to extract number from text string

    Hello All,
    Please help me to extract the number from the text string. Please see sample in attached

    Regards,
    tt3
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Need Formula to extract number from text string

    Hi there. Your examples may be random. I hope they are... In your real strings - do you have things like 23GHY - with no space between the number and the letter?
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    810

    Re: Need Formula to extract number from text string

    Hi Glenn,
    Thank you for your time. Yes, because many user(s) create in their own way and the text string is their own description.

    Regards,
    tt3

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Need Formula to extract number from text string

    OK. Try this. It's a bit of a monster 'cos it's a combination of a couple of things caused by your 23GHY problem and the problem caused by the hyphens. This is is an array formula and must be ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.

    Do uyou need to use the numbers as numbers elsewhere? This formula returns them as text (which you can't add/subtract, etc). The problem is the 12-18 seqence. I'd need to make changes if you want them as real numbers. Anyway take a look and let me know. Solution in Col K. The other cols can be deleted. They're just intermediate steps, retained in case I didn't get it right first time.
    Attached Files Attached Files

  5. #5
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Need Formula to extract number from text string

    a bit shorter
    Attached Files Attached Files

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Need Formula to extract number from text string

    Nice approach. If you remove the helper columns - it's still a bit of a monster... albeit about 10 characters shorter than mine...

  7. #7
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Need Formula to extract number from text string

    Yes, but it's not volatile

  8. #8
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    810

    Re: Need Formula to extract number from text string

    Hello All,
    That's work but please look at sample again and revise the formula.

    Regards,
    tt3
    Attached Files Attached Files

  9. #9
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Need Formula to extract number from text string

    Didn't look above approaches so mine is probably longer but here it is
    Attached Files Attached Files

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Need Formula to extract number from text string

    That certainly makes life a lot simpler...
    Attached Files Attached Files
    Last edited by Glenn Kennedy; 03-28-2015 at 04:19 AM. Reason: wrong attachment.

  11. #11
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Need Formula to extract number from text string

    =MID(LEFT(A2,MAX(IF(ISNUMBER(MID(A2,ROW(1:256),1)+0),ROW(1:256)))),MIN(IF(ISNUMBER(MID(A2,ROW(1:256),1)+0),ROW(1:256))),256)
    try this array formula, confirm with shift+Ctrl+Enter
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  12. #12
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Need Formula to extract number from text string

    Please Login or Register  to view this content.
    Inspired by Zbor

  13. #13
    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: Need Formula to extract number from text string

    Array formula in B2 and copy down

    =MID(LEFT(A2,MATCH(1,-MID(A2,ROW(A$1:A$99),1),1)),MIN(SEARCH(ROW(A$1:A$10)-1,A2&1/17)),99)

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.

    Row\Col
    A
    B
    1
    TEXT RESULT
    2
    HMP CCD ABC 12-18DWA AAA 12-18
    3
    HMP CCD 22-18D AAA 22-18
    4
    ABC CCD BOB 24D NNC 24
    5
    ABC CCD 28 D NNC 28
    6
    ALA DND 16G EWSFFSD 16
    7
    ALA DND 16DWA TRWW 16
    8
    BBC DND 28 DWA GFHGFHGF 28
    9
    ALA DND 14 G GFHFHGF 14
    10
    ALA DND 22G DSA 22


    this one is for both tables:

    ***Array formula

    =LOOKUP("zzzzz",MID(LEFT(A2,MATCH(1,-MID(LEFT(A2,LEN(A2)-5),ROW(A$1:A$99),1))),MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&1/17)),ROW($1:$1000)))
    Last edited by AlKey; 03-28-2015 at 09:35 AM.
    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

  14. #14
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    810

    Re: Need Formula to extract number from text string

    Hello All,
    All formula works but how to apply the below IF....to your Formula and I just need the first few number before D, G, DWA

    Please Login or Register  to view this content.
    Regards,
    tt3

  15. #15
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Need Formula to extract number from text string

    I am a little confused. Have you changed your requirements again? Can you repost a FINAL list of Before/After strings so that we can bring this to a close?

    Thanks!!

  16. #16
    Forum Contributor
    Join Date
    08-14-2012
    Location
    USA
    MS-Off Ver
    Excel 2007, MS 365 (Windows 10 Pro 64-bit)
    Posts
    810

    Re: Need Formula to extract number from text string

    Hi Glenn,
    I'm not changing anything but there's a lot of rows doesn't have "DND" or "CCD" and I don't want result show "#N/A".

    Please Login or Register  to view this content.
    Regards,
    tt3

+ 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. Need to extract number from Text String
    By EricJonke in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-29-2014, 11:16 AM
  2. Extract the first Number from a Text String
    By ARGK in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-23-2013, 07:36 AM
  3. [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
  4. Extract number from text string
    By jjjjj55555 in forum Excel General
    Replies: 2
    Last Post: 04-04-2007, 04:38 PM
  5. [SOLVED] Extract a number from a text string?
    By Brian in forum Excel General
    Replies: 8
    Last Post: 01-09-2006, 05:20 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