+ Reply to Thread
Results 1 to 13 of 13

Formula to delete all characters except number string

  1. #1
    Registered User
    Join Date
    06-02-2015
    Location
    Cali
    MS-Off Ver
    2010
    Posts
    27

    Cool Formula to delete all characters except number string

    Hey Guys,

    I need a formula to remove all characters except for a 12 digit numeric string.

    For example

    Cell A1 contains: content="Zendaya 10-bulb Edison Chandelier with Bulbs, LD-4901, Warehouse of Tiffany, LD-4901, 15928877, 794504104264, compare Zendaya 10-bulb Edison Chandelier with Bulbs, best price on Zendaya 10-bulb Edison Chandelier with Bulbs, discounted Zendaya 10-bulb Edison Chandelier with Bulbs, cheap Zendaya 10-bulb Edison Chandelier with Bulbs"

    Output needs to be: 794504104264

    So to clarify I would prefer the formula to pull any numeric string of 12+ characters. Thanks in advance you guys!

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2012
    Location
    Melbourne, VIC
    MS-Off Ver
    Excel 2016
    Posts
    750

    Re: Formula to delete all characters except number string

    you can use "Text to columns" feature (with space & comma as delimiters) to split the long string into individual blocks of string and then apply the Max function on the cells to extract the 12+ digit number. (This approach assumes that there would be only 1 such number in all the split strings).
    • Say A1 contains the large string as above:
    • Apply Text to Column with comma & space as delimiters.
    • Check the box "Treat Consecutive delimiters as one".
    • this particular string would split from A1 to AQ1.
    • Now use the formula, MAX(1:1) to extract the number: 794504104264
    HTH!

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

    Re: Formula to delete all characters except number string

    Try array entering this formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If you aren’t familiar with array-entered formulae array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Dave

  4. #4
    Registered User
    Join Date
    06-02-2015
    Location
    Cali
    MS-Off Ver
    2010
    Posts
    27

    Re: Formula to delete all characters except number string

    Flame,

    The formula you provided works half the time. Two things that are happening.

    1. The first and last number are sometimes dropped if the string starts or ends with a 0.

    2. Sometimes no value is pulled and the output is a 0.

    For example:
    content="Athena 26-inch Swivel Counter Stool, AH225-26-AR-649, AH225-26-AR-649, 14257186, 739901002287, compare Athena 26-inch Swivel Counter Stool, best price on Athena 26-inch Swivel Counter Stool, discounted Athena 26-inch Swivel Counter Stool, cheap Athena 26-inch Swivel Counter Stool"

    Output is = 0
    Actual output should be:739901002287

    Any additional help would be greatly appreciated. Thanks you guys

  5. #5
    Registered User
    Join Date
    06-02-2015
    Location
    Cali
    MS-Off Ver
    2010
    Posts
    27

    Re: Formula to delete all characters except number string

    Book1.xlsx

    I have attached the file with the content. Thanks again!

  6. #6
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Formula to delete all characters except number string

    assuming your data is in A1 then in B1 copy paste below then hold control and shift together and then hit enter to make it array formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Array formulas are...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.
    Last edited by hemesh; 02-08-2016 at 03:12 PM.
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    WANT TO SAY THANKS, HIT ADD REPUTATION (*) AT THE BOTTOM LEFT CORNER OF THE POST

    More we learn about excel, more it shows us, how less we know about it.

    for chemistry
    https://www.youtube.com/c/chemistrybyshivaansh

  7. #7
    Registered User
    Join Date
    06-02-2015
    Location
    Cali
    MS-Off Ver
    2010
    Posts
    27

    Re: Formula to delete all characters except number string

    Hemesh,

    Your solution works perfectly, only issue I could find is that it drops a 0 if the the string starts with a 0. Any easy fix? Thanks!

  8. #8
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Formula to delete all characters except number string

    Try this.
    I've noticed the pattern that the desired number is always followed by , compare

    =TRIM(RIGHT(SUBSTITUTE(LEFT(A2,FIND(", compare",A2)-1)," ",REPT(" ",LEN(A2))),LEN(A2)))

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Formula to delete all characters except number string

    There were a few cases where there were multiple consecutive numbers seperated by only a comma.
    Such as 095385823894,095385798260,095385798307, compare in A30.

    This will correct for that
    =TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(LEFT(A2,FIND(", compare",A2)-1),","," ")," ",REPT(" ",LEN(A2))),LEN(A2)))

  10. #10
    Registered User
    Join Date
    06-02-2015
    Location
    Cali
    MS-Off Ver
    2010
    Posts
    27

    Re: Formula to delete all characters except number string

    Jonmo1.

    Your formula worked perfectly. Thank you for everyone taking the time to look over this for me. Reputation will be added.

  11. #11
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Formula to delete all characters except number string

    updated formula in post #6

  12. #12
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Formula to delete all characters except number string

    You're welcome.

  13. #13
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Formula to delete all characters except number string

    you are welcome and thanks for the feedback

+ 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. Delete Characters Before Last Space In Text String [SOLVED]
    By alacey425 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-01-2016, 11:30 PM
  2. Replies: 2
    Last Post: 01-02-2015, 08:57 PM
  3. delete last 5 characters from string
    By leooconnor in forum Excel General
    Replies: 6
    Last Post: 01-02-2015, 08:50 PM
  4. [SOLVED] Delete specific characters from right side of string
    By Drudnits1 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-29-2014, 02:12 PM
  5. Replies: 7
    Last Post: 07-25-2014, 08:21 AM
  6. Replies: 4
    Last Post: 12-08-2010, 01:28 PM
  7. Replies: 5
    Last Post: 05-15-2006, 01:15 PM

Tags for this Thread

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