+ Reply to Thread
Results 1 to 17 of 17

How to create new rows when a cell has data separated by a comma

  1. #1
    Registered User
    Join Date
    04-08-2017
    Location
    BKK
    MS-Off Ver
    Office 2016
    Posts
    23

    How to create new rows when a cell has data separated by a comma

    Hi Everyone,

    I need some help here to either automate or write certain formulas whereby I need to create a new row whenever 1 of the cell have data seperate by comma.

    E.g.

    Please Login or Register  to view this content.
    The end result should look like this

    Please Login or Register  to view this content.
    someone have a similar questions and solution in another thread
    https://www.excelforum.com/excel-for...ml#post4625320

    My dataset is about 100,000 - Less than a million records but I've to do it every quarter.
    I'm wondering if VBA/Macro would be a better choice. If so how do i go around exploring it since i'm relatively new to VBA / Macro

    Btw, i'm using Excel 2016

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: How to create new rows when a cell has data separated by a comma

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential information is removed first!!

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

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

    Re: How to create new rows when a cell has data separated by a comma

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 04-08-2017 at 10:23 AM.
    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.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,944

    Re: How to create new rows when a cell has data separated by a comma

    Using Glenn's solution:

    on Sheet2 :

    in B2

    =IFERROR(TRIM(MID(SUBSTITUTE(","&INDEX(Sheet1!$B$2:$B$5,MATCH(A2,Sheet1!$A$2:$A$5,0)),",",REPT(" ",125)),125*COUNTIF($A$2:A2,A2),125)),"")

    With "helper" column in F of Sheet1.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    04-08-2017
    Location
    BKK
    MS-Off Ver
    Office 2016
    Posts
    23

    Re: How to create new rows when a cell has data separated by a comma

    Thanks John,

    I looked through your fomula, i'm trying to understand why "125' ? I mean what does "125" mean in this formula

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    04-08-2017
    Location
    BKK
    MS-Off Ver
    Office 2016
    Posts
    23

    Re: How to create new rows when a cell has data separated by a comma

    @mehmetcik,

    Thanks for this code. Does this Macro, create a new workbook after running the macro?
    Or is creating a new worksheet?

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

    Re: How to create new rows when a cell has data separated by a comma

    It modifies your existing sheet.

    There is no mention of a new worksheet or new workbook in post 1.

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 04-08-2017 at 10:22 AM.

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,944

    Re: How to create new rows when a cell has data separated by a comma

    The 125 is "just" a number which is likely to be longer than any subset of the string to ensure that the extracted strings don't overlap: often the"default" is 255 but others use 100- take your pick!

    The formula is credited to Glenn not me.

  9. #9
    Registered User
    Join Date
    04-08-2017
    Location
    BKK
    MS-Off Ver
    Office 2016
    Posts
    23

    Re: How to create new rows when a cell has data separated by a comma

    @John,

    Thanks, I understand the formula now

  10. #10
    Registered User
    Join Date
    04-08-2017
    Location
    BKK
    MS-Off Ver
    Office 2016
    Posts
    23

    Re: How to create new rows when a cell has data separated by a comma

    @mehmetcik,

    apologize for not being clear. If i were to use the first Macro, will it remove the original data?

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

    Re: How to create new rows when a cell has data separated by a comma

    No.

    The original data is untouched.

  12. #12
    Registered User
    Join Date
    04-08-2017
    Location
    BKK
    MS-Off Ver
    Office 2016
    Posts
    23

    Re: How to create new rows when a cell has data separated by a comma

    Thanks. I tried the formula and it works perfect.
    Next step is working on the Macro

    @mehmetcik... Sorry, just a few more questions on your 2nd Macro;
    Seem like the new data is populated at column G?
    If I don't know what is the last row of my data, what is the syntax to replaced '5'?

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

    Re: How to create new rows when a cell has data separated by a comma

    I do not understand your question.

    You do not need to know where the last row is, it will run until there are no commas in column B.

    Which 5 are you replacing and why?

  14. #14
    Registered User
    Join Date
    04-08-2017
    Location
    BKK
    MS-Off Ver
    Office 2016
    Posts
    23

    Re: How to create new rows when a cell has data separated by a comma

    I haven to get the chance to try it at work, prob tries it over the weekend.


    Please Login or Register  to view this content.
    I assume the '5' is because there is only 5 row of data in the sample sheet but my original data have more than 5 rows and varies across each sheet. What should be replaced to run till the last available data?

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

    Re: How to create new rows when a cell has data separated by a comma

    if Z.row =25 and the number of Commas A =4

    The line
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    means:

    Copy Range("A25:E25") to Range("A25:E29")

  16. #16
    Registered User
    Join Date
    04-08-2017
    Location
    BKK
    MS-Off Ver
    Office 2016
    Posts
    23

    Re: How to create new rows when a cell has data separated by a comma

    @mehmetcik ... Thanks for educating me on this appreciate your help

    @Moderator How do i mark this thread as closed or solved?

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,231

    Re: How to create new rows when a cell has data separated by a comma

    Please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

+ 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. INDEX & MATCH multiple rows to return comma separated cell
    By sifuchi in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-18-2015, 04:36 PM
  2. Macro to create a list of sheets, separated with comma in a single cell
    By manolomana in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2014, 11:00 AM
  3. graphs from comma separated data in one cell
    By kirkendall in forum Excel General
    Replies: 0
    Last Post: 09-12-2012, 08:31 AM
  4. [SOLVED] separate cell with comma separated data into one column
    By Tenos in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2012, 02:45 PM
  5. Replies: 8
    Last Post: 01-29-2010, 09:31 AM
  6. combine rows into one cell separated by comma
    By Miki Jo in forum Excel General
    Replies: 2
    Last Post: 03-09-2006, 04:30 PM
  7. Replies: 2
    Last Post: 02-15-2005, 07:12 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