+ Reply to Thread
Results 1 to 23 of 23

Extracting Numbers Out of String

  1. #1
    Registered User
    Join Date
    03-01-2016
    Location
    DELHI, INDIA
    MS-Off Ver
    2013
    Posts
    46

    Extracting Numbers Out of String

    Hi Everyone,

    I need help.

    I want to extract only numbers from right out of a string

    Examples of My string are :

    1. Asia Pacific Billing ATT-14-015(eForm # 20282614)

    2. Asia Pacific Billing ATT-14-018v2(eForm # 202938)

    3. Asia Pacific Billing -eForm # 2024585

    As you can see in some examples there are bracket and number count also varies from example to example.

    Kindly help.

    I just want the number shown in from of eform #

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

    Re: Extracting Numbers Out of String

    Here:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  3. #3
    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,209

    Re: Extracting Numbers Out of String

    Try

    =SUBSTITUTE(MID(A1,FIND("#",A1)+1,255),")","")+0

  4. #4
    Registered User
    Join Date
    03-01-2016
    Location
    DELHI, INDIA
    MS-Off Ver
    2013
    Posts
    46

    Re: Extracting Numbers Out of String

    Thank You Everyone.

    But if "#" is not present there, then it is showing error.

    Kindly Help.

  5. #5
    Registered User
    Join Date
    03-01-2016
    Location
    DELHI, INDIA
    MS-Off Ver
    2013
    Posts
    46

    Re: Extracting Numbers Out of String

    Hi Everyone,

    Please also consider below examples also so that one formula can be defined for all example.


    1. Asia Pacific Billing ATT-14-015(eForm # 2028264) Australia
    2. Asia Pacific Billing ATT-14-018v2(eForm # 202938) Sri Lanka
    3. Asia Pacific Billing -eForm # 2024585 England

    Thanking You.

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extracting Numbers Out of String

    This is one way.
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    1. Asia Pacific Billing ATT-14-015(eForm # 2028264) Australia
    2028264
    2. Asia Pacific Billing ATT-14-018v2(eForm # 202938) Sri Lanka
    202938
    3. Asia Pacific Billing -eForm # 2024585 England
    2024585
    Dave

  7. #7
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Extracting Numbers Out of String

    Hi
    See if this helps you
    Try
    =AGGREGATE(14,6,VALUE(MID(MID(A1,AGGREGATE(14,6,FIND(" ",A1,ROW($A1:$A255)),1),999),1,ROW($A1:$A255))),1)

  8. #8
    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,209

    Re: Extracting Numbers Out of String


    I just want the number shown in from of eform #

    BUT .....

    But if "#" is not present there, then it is showing error
    .... appears to conflict.

    Dave has given you a solution But it still assumes a # is present.

  9. #9
    Registered User
    Join Date
    03-01-2016
    Location
    DELHI, INDIA
    MS-Off Ver
    2013
    Posts
    46

    Re: Extracting Numbers Out of String

    Yes Mr. John you are right, but I am talking of other case in which # is not present.

    For Eg.

    Asia Pacific Billing -eForm 2024585 England

    Asia Pacific Billing ATT-14-018v2(eForm 202938) Sri Lanka

    Kindly Help.

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extracting Numbers Out of String

    Will eForm always be present?

    Edit

    If it is this would be another way.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by FlameRetired; 05-03-2016 at 04:29 AM.

  11. #11
    Registered User
    Join Date
    03-01-2016
    Location
    DELHI, INDIA
    MS-Off Ver
    2013
    Posts
    46

    Re: Extracting Numbers Out of String

    Thank You Dave,

    But it is not necessary eform would be present, there can be random text den numbers.

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extracting Numbers Out of String

    Can you post a comprehensive list of what you will encounter? It doesn't appear that we are getting a complete picture so far.

    Maybe even a list of the countries in a lookup table?
    Last edited by FlameRetired; 05-03-2016 at 05:25 AM.

  13. #13
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Extracting Numbers Out of String

    With UDF VBA regex (first read here) you can use simply function:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    I assumed there is no less than 6 digits and no more than 8 digits in extracted number. If any number has more or less digits simply change values checked as red.
    (based on your example)

  14. #14
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Extracting Numbers Out of String

    Try this
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    03-01-2016
    Location
    DELHI, INDIA
    MS-Off Ver
    2013
    Posts
    46

    Re: Extracting Numbers Out of String

    Hi Dave,

    Please find attached sample.
    Attached Files Attached Files

  16. #16
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Extracting Numbers Out of String

    Hi @manav1103
    Have you try the formula I put in post #14?

  17. #17
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extracting Numbers Out of String

    With a lookup table of countries in column E this formula in B1 and down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

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

    Re: Extracting Numbers Out of String

    this will extract last number but must have space before it:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Please Login or Register  to view this content.
    Last edited by zbor; 05-03-2016 at 06:44 AM.

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

    Re: Extracting Numbers Out of String

    Extend 255 if you have more than 255 characters in a cell

  20. #20
    Registered User
    Join Date
    09-20-2010
    Location
    Cape Town, South Africa
    MS-Off Ver
    Excel 2000
    Posts
    2

    Re: Extracting Numbers Out of String

    Try the following custom function.

    Calling cell would contain
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    where
    S is the string containing the number
    N=instance of number if there are more than one, +ve counting from the left and -ve counting from the right (default is 1 (first from left))
    D = True if Decimals are to be recognised, False if Integer only to be returned; default id FALSE (integer only).

    Good luck
    B


    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by zbor; 05-11-2016 at 02:08 AM.

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

    Re: Extracting Numbers Out of String

    Ebyker,
    Thank you for a solution.

    Hower, please use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window.

  22. #22
    Registered User
    Join Date
    12-12-2015
    Location
    Latvia
    MS-Off Ver
    MS Office 2016
    Posts
    13

    Re: Extracting Numbers Out of String

    You dont need all above formulas. Write manually 2028264 on the first next cell, select on that cell and go to Fill>Flash Fill. Easy than any complicated formula or Macro!

  23. #23
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Extracting Numbers Out of String

    Quote Originally Posted by 7absinth View Post
    You dont need all above formulas. Write manually 2028264 on the first next cell, select on that cell and go to Fill>Flash Fill. Easy than any complicated formula or Macro!
    Very good 7absinth, welcome to the forum and thank you . I've always done Flash fill by double-clicking the fill handle. I was never aware of this secondary(?) method. I must remember this trick. It worked.

    You get rep on your first post.

+ 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 from the string
    By essai2008 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-02-2014, 08:39 PM
  2. Extracting numbers from a String?
    By lolgiggleman in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-12-2014, 06:16 AM
  3. [SOLVED] extracting numbers from a string of text and numbers
    By ScottLor in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-05-2013, 04:47 PM
  4. Excel 2007 : Extracting Numbers from A String
    By pxoxyx in forum Excel General
    Replies: 6
    Last Post: 04-28-2010, 01:43 AM
  5. Extracting Numbers a from String
    By ratcat in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-25-2009, 11:13 AM
  6. [SOLVED] Extracting numbers of a string
    By Apaxe2000 in forum Excel General
    Replies: 4
    Last Post: 05-12-2006, 11:15 AM
  7. [SOLVED] extracting numbers from string
    By Chris Dowell via OfficeKB.com in forum Excel General
    Replies: 1
    Last Post: 01-12-2005, 06: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