+ Reply to Thread
Results 1 to 8 of 8

Split comma separated entries to new row

  1. #1
    Registered User
    Join Date
    02-19-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    4

    Split comma separated entries to new row

    Hey everybody,

    I almost found what I am looking for in this thread (see link) as I was trying to split comma separated entries in some column to a new row.
    This means that for each row in which there is a comma separated list in column P with, say 5 entries, there should be generated 4 other rows below such that eventually in each row in this column there is one entry. As for the other cells in each of those 4 rows, the cells should just be copied.

    http://www.excelforum.com/excel-prog...ml#post3590704

    I managed to adjust the code from above:

    Please Login or Register  to view this content.
    However, there is one feature missing for my spreadsheet: In column O I need to number each of the entries of the list.
    So suppose there is a list of 4 entries in some row. Now I need the first row in column O to have a 1, the second to have a 2 etc.

    I would very much appreciate your help.
    Thanks a lot!
    trefix

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Split comma separated entries to new row

    see two lines added:
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    02-19-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Split comma separated entries to new row

    Unfortunately it generates an Error 1004: application or object-defined error.
    Sorry, I don't know if that's the correct translation cause I am using it in German

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Split comma separated entries to new row

    well,
    looking again on the code, I can see that it probably stops at (choose "debug" when error message pops out, and see what line is highlihjted in yellow)
    Please Login or Register  to view this content.
    But this is a line which was already in your original code .
    Nevertheless, after next look I think it will be better to use down-up_loop, not every_cell_in_a_range loop.
    every_cell_in_a_range loop is not effective, because after splitting some cell (say P15 which contained aaa,bbb,ccc) into P15, P16 and P17 the procedure will check P16 (now with bbb) and P17 (ccc).
    I also changed inner loop for copying values into single line.

    Try this version:
    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Split comma separated entries to new row

    Please Login or Register  to view this content.
    CCell is defined as a Range. Ranges must use "Set"

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Split comma separated entries to new row

    Hi stnkynts,

    CCell is set a few lines earlier:
    Please Login or Register  to view this content.
    so here
    Please Login or Register  to view this content.
    it is equivalent to
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Split comma separated entries to new row

    You are correct. I missed the earlier one.

  8. #8
    Registered User
    Join Date
    02-19-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Split comma separated entries to new row

    Thank you guys, especially Kaper! The code works perfectly fine! Now I can go on working on it using STATA
    I am afraid the wrong line stems from my early attempts to resolve the issues myself. I am sorry for the confusion! But well, you found it out anyway

    Thanks & Cheers!

+ 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. Split comma separated entries to new rows
    By dandi10 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-02-2020, 07:59 PM
  2. [SOLVED] VBA: To Split comma separated entries to new rows
    By Cytokine in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-19-2014, 08:58 PM
  3. [SOLVED] Split comma separated text and insert into next row retaining all other columns.
    By saidineshbabu in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-17-2013, 03:25 AM
  4. [SOLVED] Split the contents of the cell separated by comma into different cells
    By VivekBhise in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-30-2012, 06:50 AM
  5. Replies: 4
    Last Post: 09-04-2010, 03:37 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