+ Reply to Thread
Results 1 to 10 of 10

To extract number from string using excel formula

  1. #1
    Registered User
    Join Date
    11-14-2022
    Location
    chennai
    MS-Off Ver
    2016
    Posts
    30

    To extract number from string using excel formula

    Dear Pros,

    I am looking for a formula to extract the number in the string, the string contains multiple instances along with numbers, special characters, texts as below example

    Column A - A1 - 12345-abcded;34567-mnopq;098776-xyzopq

    the result should be

    Column B - B1 - 12345;34567;09776

    Thanks in advance

    regards
    Jaffar

  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
    43,959

    Re: To extract number from string using excel formula

    Hi. Before we get going on this one...

    Is your forum profile showing the Excel PRODUCT that you need this request to work with? In Excel 2016, you may need helper columns or VBA. Which do you prefer?

    The best solutions often rely on knowing WHICH Office PRODUCT (Excel, NOT Windows) that you have. Please check that your forum profile is up-to-date. If you aren't sure, in Excel go to File/Account and report what it says below the MS logo at the top of that page. If your version is for Mac, please also state this.

    The three most recent Excel PRODUCTS are Excel 2019, Excel 2021 and MS365 - if you are using MS365, please give this name along with the Version number in your profile (e.g. MS365 (PC) Version 2211). The version number is in the About Excel section further down the Account page.

    Cheers,

    Glenn.
    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 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
    43,959

    Re: To extract number from string using excel formula

    This array formula returns them one number in each cell. If you want tehm concatendated into a single cell, you will need VBA.

    This works with your one, lonely, miserable, isolated, single example. It may not work with your complete dataset, as one sample may not be representative of the whole.

    =TRANSPOSE(FILTERXML("<A><B>"&SUBSTITUTE(SUBSTITUTE(A1,";","-"),"-","</B><B>")&"</B></A>","//B[.*0=0]")

    Array formulae are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see the curly brackets { } appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    11-14-2022
    Location
    chennai
    MS-Off Ver
    2016
    Posts
    30

    Re: To extract number from string using excel formula

    Dear Glenn,
    Thanks again for the formula, great the formula is working in excel column, but also i am trying to use the formula under VBA formula property, but it is not working.
    Is there any way around i can use the formula in vba? or if possible can you provide the formula in VBA version?
    thanks

  5. #5
    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
    43,959

    Re: To extract number from string using excel formula

    I can not help. I know nothing about VBA. You aked for a formula. That is why I tried to help. It is easy if you have a more modern version of Excel, biut not with Excel 2016.

  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,133

    Re: To extract number from string using excel formula

    Please Login or Register  to view this content.

    =get_n(A1)
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

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

    Re: To extract number from string using excel formula

    Or try

    Please Login or Register  to view this content.
    Using: =ExtractNumber(A1)

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

    Cool Re: To extract number from string using excel formula

    or try Power Query, no formula, no vba

    Column1 Result
    12345-abcded;34567-mnopq;098776-xyzopq 12345;34567;098776


    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    11-14-2022
    Location
    chennai
    MS-Off Ver
    2016
    Posts
    30

    Re: To extract number from string using excel formula

    Thank you so much Glenn, John, Phuocam, Sandy.
    You guys amazing, you are always make our life easy. Keep it up.

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

    Re: To extract number from string using excel formula

    You are welcome

+ 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] Formula to Extract Number from a String
    By Barieq in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-03-2021, 01:43 PM
  2. Formula to Extract Number from a String
    By Barieq in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-02-2021, 05:09 PM
  3. Formula to extract largest number from a string for Politics Dissertation
    By harryspooner in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 05-31-2019, 11:54 AM
  4. [SOLVED] Formula to extract number from a string
    By Bobbbo in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-28-2017, 03:04 AM
  5. 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
  6. Replies: 12
    Last Post: 08-14-2014, 11:37 AM
  7. [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

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