+ Reply to Thread
Results 1 to 8 of 8

Extract all numbers from cells with varying lengths

  1. #1
    Registered User
    Join Date
    10-25-2017
    Location
    United States
    MS-Off Ver
    2019
    Posts
    63

    Extract all numbers from cells with varying lengths

    I have a worksheet that has different values with varying lengths and I am looking to extract all numbers from each cell. I have attached my workbook, current formula and the solution I am trying to arrive at. I understand my formula is replacing all "-" with " ", but would like to keep those if possible.

    Current formula:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Thank you for your help!
    Attached Files Attached Files

  2. #2
    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: Extract all numbers from cells with varying lengths

    Try array entering this formula in C2 and fill down.

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


    If you have thousands of these the formula will need some modification.
    Dave

  3. #3
    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: Extract all numbers from cells with varying lengths

    That formula needs an extra step. I forgot to remove the ","s. Try this ... still array entered.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    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: Extract all numbers from cells with varying lengths

    Regular formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    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

  5. #5
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: Extract all numbers from cells with varying lengths

    try this array formula(CSE)
    =SUBSTITUTE(SUBSTITUTE(MID(LEFT(A2,MAX(IF(ISNUMBER(--MID(A2,ROW($1:$255),1)),ROW($1:$255)))),MIN(IF(ISNUMBER(--MID(A2,ROW($1:$255),1)),ROW($1:$255))),LEN(A2)),",",),"$","")

    copy down

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

    Cool Re: Extract all numbers from cells with varying lengths

    or try PowerQuery add-in for Ex2013 Pro Plus (free from MS site)

    Look at Result table (you can see but it doesn't work without add-in)

  7. #7
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Extract all numbers from cells with varying lengths

    A non array solution

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Extract all numbers from cells with varying lengths

    =ReplaceIt(A2)

    for anyone who prefers shorter formulas

    UDF (code in standard module)
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

+ 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. Replies: 9
    Last Post: 06-09-2016, 10:28 AM
  2. Need to extract specific but varying length and location numbers from description
    By 5bigun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-08-2016, 10:39 AM
  3. [SOLVED] Extract numbers of variable lengths from cell
    By Nizz in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-18-2013, 10:11 AM
  4. [SOLVED] Concatenate with varying lengths and data
    By Unident in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-21-2013, 04:39 PM
  5. Best way to store lists of varying lengths
    By jik_ff in forum Access Tables & Databases
    Replies: 5
    Last Post: 04-17-2013, 08:54 AM
  6. Replies: 3
    Last Post: 05-09-2012, 11:36 AM
  7. Apply Macro to varying row lengths
    By izza56 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-08-2006, 10:36 AM

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