+ Reply to Thread
Results 1 to 17 of 17

Extract numbers from a cell keeping the quantities together

  1. #1
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    221

    Extract numbers from a cell keeping the quantities together

    Thanks you in advanced.

    I have a cell (say G11) which contains the following: 2+12+55+1+0+16+555+1=

    I need to extract all the numbers (automatically, with a formula or VB) into different cells (to a row of cells, or column) keeping each quantity in it's own cell, for example:

    2 will be in it's own cell
    12 will be in it's own cell
    55 will be in it's own cell
    1 will be in it's own cell
    and so on...

    Obviously, I do not want the "+" or "=" or any other part of the string... just the quantities. This has to be in place so that it changes on it's own without user input... the only cell that will have user input is the first one that contains everything.

    I've tried with LEFT, MID, RIGHT, VLOOKUP, etc... but LEFT only does one number starting from the left, RIGHT only get the whole number from the right, and MID only one number in the middle... but as you see, I have more numbers than just 3 quantities.
    Last edited by Luisftv; 11-18-2018 at 01:39 PM. Reason: spelling error in the title

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Extrat numbers from a cell keeping the quantities together

    A Macro will be easiest.

    Copy the value of the cell to vba.

    Check every character and replace all non numericals with "+"

    Replace every "++" with "+" until all replaced

    Use the Split function
    Please Login or Register  to view this content.
    to read the text in to an array.

    Write the Array back to excel.

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 11-17-2018 at 01:36 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,957

    Re: Extrat numbers from a cell keeping the quantities together

    Try this. I have given it both ways...
    G
    H
    I
    J
    K
    L
    M
    N
    O
    P
    11
    2+12+55+1+0+16+555+1 2 2 12 55 1 0 16 555 1
    12
    12
    13
    55
    14
    1
    15
    0
    16
    16
    17
    555
    18
    1


    H11=TRIM(MID(SUBSTITUTE($G$11,"+",REPT(" ",LEN(G$11))),LEN($G$11)*(ROW()-11)+1,LEN($G$11)))
    copied down

    OR
    I11=TRIM(MID(SUBSTITUTE($G11,"+",REPT(" ",LEN($G11))),LEN($G11)*(COLUMN()-9)+1,LEN($G11)))
    copied across

    Note that in both cases, you may need to adjust the minus values after either ROW() or COLUMN(), depending on where you want the answers to show.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    221

    Re: Extrat numbers from a cell keeping the quantities together

    Thank you so much FDibbins.

    Your awesome formula works (almost) perfectly...

    Cell G11 has: 2+12+55+1+0+16+555+1=

    Therefore, that "=" sign is added to the last number... I need that = sign gone...

    Other than that is awesome.

    I was trying to attach the excel file here but the attachment button does not work... sorry.

    Thank you so much.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Extrat numbers from a cell keeping the quantities together

    This has been reported as being cross posted elsewhere and as such does not comply with Rule 3 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    Please make sure to include the full link, so that other members will be permitted to continue helping you

    Note that if you have fewer than 10 posts, you may need to type the link, or past it in pieces (or ask a mod to do that for you)
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  6. #6
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    221

    Extrat numbers from a cell keeping the quantities together

    I APOLOGIZE FOR THE DOUBLE POSTING...

    I honestly didn't know...

    Also, I didn't know that both forums were connected...

    So far, this forum has given me a good answer...

    I will go and delete the post from the other forum... if I figure how to... I already tried right after I made the account... is so confusing that process.


    TO BE FAIR... I did tried to include the link, but I got this message from this forum when I tried:


    Errors
    The following errors occurred with your submission
    You are not allowed to post any kinds of links, images or videos until you post a few times.


    There you have it... SORRY. BUT I did tried... yes, it was my first posting on this site.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,558

    Re: Extrat numbers from a cell keeping the quantities together

    As you are a new member, I shall provide the link this time: https://www.mrexcel.com/forum/excel-...-together.html

    Please note what Richard has said above and provide cross-post information yourself if you do this again in future. Thank you.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  8. #8
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    221

    Re: Extrat numbers from a cell keeping the quantities together

    Yes, AliGW, I am absolutely a NEW MEMBER... as a matter of fact, it is the first time in my life that I sign up to a forum or anything... I only have an Amazon account and that's all, besides my email obviously.

    Again, I apologize...

    I'm trying to delete the other forums post and account and I can't...

    I will try again later... I have to step out of the office for a while.

    Thank you again.

    Once again, I

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,558

    Re: Extrat numbers from a cell keeping the quantities together

    You don't need to delete your account on the other forum. You just need to read and obey the rules of the two forums you have joined: both forums require you to disclose cross-posting.

    As a new member to ANY forum, the very FIRST thing you should do is read the rules. Ours are very easy to find - there is a link at the top of this page. Please take a moment to read them now. Thanks.

  10. #10
    Registered User
    Join Date
    06-04-2018
    Location
    Europe
    MS-Off Ver
    Office365
    Posts
    78

    Re: Extrat numbers from a cell keeping the quantities together

    @mehmetcik,

    I tried the code you provided but did not list the rightmost number (here number 1)


    2+12+55+1+0+16+555+1 _____ 2 12 55 1 0 16 555

  11. #11
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    221

    Re: Extrat numbers from a cell keeping the quantities together

    AliGW... thank you. I'll sure do that.


    Tommy90

    Drag the cell until you see blanks... you simply didn't drag far enough...


    -------------------------------------------

    FDibbins

    Thank you for your help.

    Please, can you tell me how to remove the "=" sign from the last number?

    Remember that the original cell G11 does contain the "=" sign.

    Thank you so much.

  12. #12
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Extrat numbers from a cell keeping the quantities together

    Thanks Tommy,

    I didn't notice that.

    Please change the last line to:

    Please Login or Register  to view this content.

  13. #13
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,957

    Re: Extrat numbers from a cell keeping the quantities together

    Quote Originally Posted by Luisftv View Post
    Thank you so much FDibbins.

    Your awesome formula works (almost) perfectly...

    Cell G11 has: 2+12+55+1+0+16+555+1=

    Therefore, that "=" sign is added to the last number... I need that = sign gone...

    Other than that is awesome...
    Try these...
    H11=SUBSTITUTE(TRIM(MID(SUBSTITUTE($G$11,"+",REPT(" ",LEN(G$11))),LEN($G$11)*(ROW()-11)+1,LEN($G$11))),"=","")
    or
    I11=SUBSTITUTE(TRIM(MID(SUBSTITUTE($G11,"+",REPT(" ",LEN($G11))),LEN($G11)*(COLUMN()-9)+1,LEN($G11))),"=","")

    Regarding the duplicate posts on other forums, we are not affiliated, but many of us are members on more than 1 forum - it's not a big deal at all The problem comes in when a member posts the same question in multiple forums, but does not share a link to those other forums.
    When that happens, members on each forum could be trying to assist you, but you may already have an answer from 1 of the forums. That means that all the other members trying to help you, have wasted their time on you. Providing links helps eliminate that

  14. #14
    Registered User
    Join Date
    06-04-2018
    Location
    Europe
    MS-Off Ver
    Office365
    Posts
    78

    Re: Extrat numbers from a cell keeping the quantities together

    Thanks mehmetcik

  15. #15
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    221

    Re: Extrat numbers from a cell keeping the quantities together

    Quote Originally Posted by FDibbins View Post
    Try these...
    H11=SUBSTITUTE(TRIM(MID(SUBSTITUTE($G$11,"+",REPT(" ",LEN(G$11))),LEN($G$11)*(ROW()-11)+1,LEN($G$11))),"=","")
    or
    I11=SUBSTITUTE(TRIM(MID(SUBSTITUTE($G11,"+",REPT(" ",LEN($G11))),LEN($G11)*(COLUMN()-9)+1,LEN($G11))),"=","")

    Regarding the duplicate posts on other forums, we are not affiliated, but many of us are members on more than 1 forum - it's not a big deal at all The problem comes in when a member posts the same question in multiple forums, but does not share a link to those other forums.
    When that happens, members on each forum could be trying to assist you, but you may already have an answer from 1 of the forums. That means that all the other members trying to help you, have wasted their time on you. Providing links helps eliminate that


    THANK YOU!!!!!

    It works perfectly.


    About the forum... you make perfect sense and I agree. Thanks again.

  16. #16
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    221

    Re: Extrat numbers from a cell keeping the quantities together

    Quote Originally Posted by mehmetcik View Post
    A Macro will be easiest.

    Copy the value of the cell to vba.

    Check every character and replace all non numericals with "+"

    Replace every "++" with "+" until all replaced

    Use the Split function
    Please Login or Register  to view this content.
    to read the text in to an array.

    Write the Array back to excel.

    Please Login or Register  to view this content.

    Thank you mehmetcik for your help. I appreciate it.

  17. #17
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,957

    Re: Extract numbers from a cell keeping the quantities together

    Happy to help, thanks for the understanding and feedback

    On a side note, there is no need to quote whole posts -- it's just clutter. If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding

    For normal conversational replies, try using the QUICK REPLY box below.

+ 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] Add up the quantities of numbers present in each letter in column.
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-03-2018, 10:37 AM
  2. Replies: 8
    Last Post: 12-30-2016, 09:08 AM
  3. [SOLVED] Summation of Quantities for Duplicate Part Numbers - VBA Help please
    By longbow007 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-09-2016, 12:42 AM
  4. Replies: 10
    Last Post: 08-26-2013, 04:25 PM
  5. [SOLVED] Keeping the formula connected to the cell rather than the numbers
    By Bucket in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-21-2013, 03:30 AM
  6. [SOLVED] Removing characters from a cell (keeping only the numbers)
    By Monk in forum Excel General
    Replies: 9
    Last Post: 01-24-2006, 11:35 AM
  7. [SOLVED] Removing characters from a cell (keeping only numbers) 2
    By Monk in forum Excel General
    Replies: 6
    Last Post: 01-24-2006, 10:50 AM

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