+ Reply to Thread
Results 1 to 8 of 8

Formula to extract number

  1. #1
    Forum Contributor
    Join Date
    07-01-2009
    Location
    Maine, USA
    MS-Off Ver
    Excel 2016
    Posts
    161

    Formula to extract number

    I have a cell that has a lot of text in it. It may look like the following:

    Please Login or Register  to view this content.
    The commonality is that the numbers are always followed by a space and PLN (such as " PLN") and preceded by a comma. Is there a way I can extract just the number? I can write a formula for something such as between parenthesis, but not for two different characters. The first comma is us

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,890

    Re: Formula to extract number

    Were you about to say that the first comma is not always the comma which indicates the start of the number?

    Pete

  3. #3
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,204

    Re: Formula to extract number

    If you're happy with a UDF, how about
    Please Login or Register  to view this content.
    Used like =GetNumber(A1)

  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 2406
    Posts
    44,629

    Re: Formula to extract number

    Ordinary formula:

    =-LOOKUP(1,-RIGHT(TRIM(LEFT(A2,FIND(" PLN",A2)-1)),{1,2,3,4,5,6,7,8,9}))

    assumes data in A2.
    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

  5. #5
    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: Formula to extract number

    Or this
    Enter in B1 and copy down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

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

    v A B
    1 Widgets, Inc., 12345 PLN 5/29/2018; 12345
    2 ABC-123: My Company, 8493 PLN 6/6/2018; 8493
    Last edited by AlKey; 08-26-2018 at 04:28 PM.
    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

  6. #6
    Valued Forum Contributor jtakw's Avatar
    Join Date
    05-05-2018
    Location
    CA, USA
    MS-Off Ver
    2016
    Posts
    668

    Re: Formula to extract number

    Hi,

    Use B1 formula in case you have "numbers" that start with 0s (zero) and you need to retain that format, result is Text.
    Use C1 formula if you want the result converted to Real Numbers, leading 0s will be dropped.
    Formulas accommodates "numbers" up to 99 characters in length.

    Excel 2016 (Windows) 64 bit
    A
    B
    C
    1
    Widgets, Inc., 12345 PLN 5/29/2018; 12345
    12345
    2
    ABC-123: My Company, 8493 PLN 6/6/2018; 8493
    8493
    3
    ABC-123: My some text Company, 008493 PLN more text 6/6/2018; 008493
    8493
    Sheet: Sheet47

    Excel 2016 (Windows) 64 bit
    B
    C
    1
    =TRIM(RIGHT(SUBSTITUTE(LEFT(A1,SEARCH("PLN",A1)-2)," ",REPT(" ",99)),99))
    =RIGHT(SUBSTITUTE(LEFT(A1,SEARCH("PLN",A1)-2)," ",REPT(" ",99)),99)+0
    Sheet: Sheet47
    Last edited by jtakw; 08-26-2018 at 05:19 PM.

  7. #7
    Forum Contributor
    Join Date
    07-01-2009
    Location
    Maine, USA
    MS-Off Ver
    Excel 2016
    Posts
    161

    Re: Formula to extract number

    Wow! Thank you for the responses! Here's replies back...

    pete_uk: you are correct. Must have gotten distracted before I clicked submit!
    fluff13: I like your VBA - I'll definitely add that to my code library, but was looking specifically for a formula in this instance.
    glenn: Worked! Even on the cells I had that had commas before the number before PLN! (hopefully, you can follow along and understand that)
    alkey: The longer one worked, but the short one didn't.
    jtakw: Thanks for the input on the preceding zeros. This instance, I don't need to keep them around, but I'll definitely keep your formula handy as I'm sure I'll probably run into it again.

    Thanks for the responses!

  8. #8
    Valued Forum Contributor jtakw's Avatar
    Join Date
    05-05-2018
    Location
    CA, USA
    MS-Off Ver
    2016
    Posts
    668

    Re: Formula to extract number

    Quote Originally Posted by mainemojo View Post
    jtakw: Thanks for the input on the preceding zeros. This instance, I don't need to keep them around, but I'll definitely keep your formula handy as I'm sure I'll probably run into it again.
    Then how about the C1 formula in my Post #6?

+ 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 a number from a sentence to use in formula?
    By ocannon1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-22-2017, 07:40 AM
  2. formula to extract number from sttring
    By cmb80 in forum Excel General
    Replies: 2
    Last Post: 04-01-2017, 12:10 AM
  3. [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
  4. [SOLVED] Formula needed to extract a number from a cell
    By Twaddy006 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-08-2016, 02:14 PM
  5. [SOLVED] Extract Number from Parenthesis for Use in Formula
    By kellyjo7 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 01-09-2015, 06:48 PM
  6. Formula to extract number only
    By tantcu in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-16-2014, 04:08 PM
  7. [SOLVED] Formula needed to extract number
    By MHamid in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-01-2013, 02:43 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