Closed Thread
Results 1 to 23 of 23

Parse multiple values in a cell into separate rows

  1. #1
    Registered User
    Join Date
    08-27-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    13

    Parse multiple values in a cell into separate rows

    I'm working with a spreadsheet (v2003) with a lotta raw data, and displaying it in a separate worksheet for executive review. The raw data is fairly easy to deal with, except for one cell that has multiple values of 5 characters, separated by commas (e.g. 4ER9G, 22WE9, 24WK7, etc) and I need to parse those into distinct rows, with all the other values of that row of data remaining the same, or all the other cells from that row remaining blank so that the new rows are only comprised of the 5-character values being parsed. Some of the cells contain 1 or 2 values, but some contain 5 or 6, which complicates a way to accomplish this. If you need more information, please let me know. Thanks in advance.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to parse mulitple values in a cell into separate rows.

    This is a VBA solution.

    I have a macro that may be "ready to use" for expanding rows of data to multiple rows parsing out the values in one column while duplicating all the others.Just edit the Col = 2 code to the column you need to expand.

    You can remove this section:
    Please Login or Register  to view this content.
    ...if you really want those new rows to have blank cells in the other columns.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-27-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: How to parse mulitple values in a cell into separate rows.

    Thanks for the quick turnaround - I'll go try it now, Appreciate your help!

  4. #4
    Registered User
    Join Date
    08-27-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: How to parse mulitple values in a cell into separate rows.

    FABULOUS - works perfectly - wish I could do more than just say 'Thank you'!. Someone's got to figure out how to buy another guy his favorite beverage on the Internet!

  5. #5
    Registered User
    Join Date
    08-27-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: How to parse mulitple values in a cell into separate rows.

    Okay Jerry - the parsing works great. However, when I parse the worksheet with all the raw data successfully, then go back to my worksheet that presents the data in a specified format, the 'presentation' worksheet does not update. I have formulas in the 'presentation' worksheet to pull the raw data - say rows 2 through 100. There are 75 rows of raw data. After running the macro to parse the multiple values into separate rows, I now have 90 rows of data, but when I go back to the 'presentation' worksheet - it continues to display only 75 rows of data instead of what is now 90 rows of data. The original data is still displaying and it does not adjust to display the new rows of data. Is there any way to get the 'presentation' worksheet to recalculate and display all 90 rows? F9 does not produce any change. Thanks for any ideas.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: How to parse mulitple values in a cell into separate rows.

    I can't comment on worksheets I can't see. Macros like this certainly don't have any thought in them as to preserving formulas of any kind. All of that is custom work.

  7. #7
    Registered User
    Join Date
    08-27-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    13

    Thumbs up Re: Parse multiple values in a cell into separate rows

    Jerry - or whomever -

    Last week Jerry provided the code for a macro that parses a cell with multiple values (separated by a comma) into separate rows. My followup question is this. Where there are empty cells, the macro is placing the parsed data into that row with an empty cell rather than inserting a new line with the appropriate data. Here is the code from last Friday, is there a modification that will enable a row with an empty cell in the specified column 6 to remain blank?



    I have removed the code as requested.



    Thanks,
    Last edited by bcullers; 08-31-2010 at 11:52 PM.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Parse multiple values in a cell into separate rows

    Be sure to read through the Forum Rules so you can use and follow them effectively. You'll must EDIT that post above and put code tags around that code you used. (Like shown in my signature and in the example below). Thanks for doing that. (you could also just remove it...)

    =========
    Take out this section and it will no longer "fill in the blanks":

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-27-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Parse multiple values in a cell into separate rows

    You're right of course, removing that portion leaves the entire row blank except for the column of data being parsed (column F). My question was not worded clearly enough.

    The column being parsed is column F (column 6), I expected all rows to have one or more values in each cell in that column, e.g. F1, F2, F3, etc. However, a few rows have no value in column F. What was occurring with the original macro was if cell F4 had two values that needed to be parsed, and cell F5 was blank but there is other data in row 5, the second value in F4 was being parsed into F5, but instead of all the other columns in row 5 containing the same values as row 4, they retained the original values of row 5 which should not be associated with the second value from F4. The macro simply took the second value from F4 and placed it into F5 instead of creating a new row for the second value from F4 and copying the other data from row 4. Hope that is more clearly worded.

    City State Zip APS # Brand Product # Date
    Dallas TX 75231 45 Ford W34FG 7/15/2010
    Plano TX 75238 75 Ford G34U8, W42GT 7/12/2010
    Ft. Worth TX 76118 45 Ford 6/3/2010
    Houston TX 77342 62 Ford Z29HY 6/22/2010

    SHOULD BE
    Dallas TX 75231 45 Ford W34FG 7/15/2010
    Plano TX 75238 75 Ford G34U8 7/12/2010
    Plano TX 75238 75 Ford W42GT 7/12/2010
    Ft. Worth TX 76118 45 Ford 6/3/2010
    Houston TX 77342 62 Ford Z29HY 6/22/2010

    Actual result
    Dallas TX 75231 45 Ford W34FG 7/15/2010
    Plano TX 75238 75 Ford G34U8 7/12/2010
    Ft. Worth TX 76118 45 Ford W42GT 6/3/2010
    Houston TX 77342 62 Ford Z29HY 6/22/2010

    Thank you,
    bcullers

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Parse multiple values in a cell into separate rows

    Surely this is simpler to discuss if you post an decent excerpt of Data sheet and we look at it together, yes?

    Click GO ADVANCED and use the paperclip icon to post up a desensitized copy of your workbook.

  11. #11
    Registered User
    Join Date
    08-27-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Parse multiple values in a cell into separate rows

    Sure - here is a spreadsheet with the sample data. Thanks.
    Attached Files Attached Files

  12. #12
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Parse multiple values in a cell into separate rows

    Please edit the post #7 as requested.


    Also, the wb does not have your edited macro in it.

  13. #13
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Parse multiple values in a cell into separate rows

    Ah, what an interesting dilemma. The column you're parsing by has blanks in it, I didn't get that before. Yes, that's an issue. But readily solvable.

    If you can't correct the code in post #7, just remove it and I'll post an enhanced version.

  14. #14
    Registered User
    Join Date
    08-27-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Parse multiple values in a cell into separate rows

    Well, glad its solvable. When I attempted to modify the code in post 7, I royally altered it and Excel kept asking me to 'Debug'. Probably like a lot of users, don't know VBA and therefore struggle with macros. I appreciate any modified code you are able to provide. I should have posted the sample data sooner, thanks again.

  15. #15
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Parse multiple values in a cell into separate rows

    Please edit post #7 and add code tags as requested, or remove the code from the post.

  16. #16
    Registered User
    Join Date
    08-27-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Parse multiple values in a cell into separate rows

    I have removed the code from post #7. Sorry for not following forum etiquette. If you have any resolution to the issue posted, I would appreciate a final suggestion, then I'll close this thread.

    Thank you,
    bcullers

  17. #17
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Parse multiple values in a cell into separate rows

    Try this. I added a step where the macro remembers all the "blanks" in column in column you are parsing and empties them again after all the other blanks are filled in the other columns.
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    08-27-2010
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Parse multiple values in a cell into separate rows

    Thank you - I sincerely appreciate the patience and assistance. Works perfectly!

  19. #19
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Parse multiple values in a cell into separate rows

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  20. #20
    Registered User
    Join Date
    05-18-2011
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Parse multiple values in a cell into separate rows

    JBeaucaire ,

    Thank you for you post. Have you had success with parsing data from multiple columns? You code has column 6 listed, which works well. What if the data comes in from a repeating table (InfoPath) and has married data parallel listed data across multiple columns.

    Project Date Budget Actual
    1234 12/09/10 12 11
    12/16/10 12 9
    12/23/10 9 4

    The data in date, budget and actual will all reside in a single column.

    Look forward to you thoughts.

  21. #21
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Parse multiple values in a cell into separate rows

    Quote Originally Posted by AWH View Post
    Please Login or Register  to view this content.
    The data in date, budget and actual will all reside in a single column.


    The data in this example does not appear to be in the same column. Demonstrating your scenarios in a workbook with data and BEFORE/AFTER sheets for your desired results makes these conversations much less theoretical.

    If you have data that LOOKS like that but is actually all in once cell, I would employ a TEXT-TO-COLUMNS routine on it to put the data into proper separate columns.

  22. #22
    Registered User
    Join Date
    01-22-2013
    Location
    Chi
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Parse multiple values in a cell into separate rows

    Hi Jerry - Sorry to revive an old thread but I found your code to be very useful and wanted to thank you for making this public.

    I do one minor enhancement - The section where you 'add the values in first column', I want to add the original values back in Column B and C etc.... Right now the code only populates the values in Column A using the conditional loop.

    Can you please make some recommendations on how I can display original values in Column B,C...

    Thanks!

    Quote Originally Posted by JBeaucaire View Post
    Try this. I added a step where the macro remembers all the "blanks" in column in column you are parsing and empties them again after all the other blanks are filled in the other columns.

  23. #23
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Parse multiple values in a cell into separate rows

    Ashar, Welcome to the Forum.

    Unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread.

    A new thread promotes faster help from our numerous contributors.

    If you feel it's particularly relevant, when creating your new thread, you can provide a link back to the thread you are referencing.


    Also, take a moment to review the forum rules at the link given. Thanks.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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