+ Reply to Thread
Results 1 to 12 of 12

Comma delimited list cell to new row code help

  1. #1
    Registered User
    Join Date
    07-07-2011
    Location
    tx
    MS-Off Ver
    Excel 2007
    Posts
    5

    Comma delimited list cell to new row code help

    Hello,

    I am trying to split any cells with multiple entries, separated by a comma, to new rows. Then I need to copy the information from the original row to the newly created rows. I have a code that will work on a test workbook, but when I run it on the workbook I the code for, it will not separate the data. Here is the code and I will attach the two file also.

    Please Login or Register  to view this content.
    Thank you for any tips or suggestions. If you have any questions please ask.
    John
    Attached Files Attached Files
    Last edited by hoovopotamus; 07-10-2011 at 03:23 PM. Reason: Problem fixed

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Comma delimited list cell to new row code help

    Hi John

    In this code
    Please Login or Register  to view this content.
    In the file that works, daRow evaluates to 15 and all your coma delimited cells are within that range...so it works. In the file that doesn't work, daRow evaluates to 87 and all the coma delimited cells fall outside that range and aren't getting evaluated.

    Welcome to the Forum!
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Comma delimited list cell to new row code help

    I haven't dug through it in detail, but I notice that the DoesWork workbook has delimited strings in column Q, while Doesn'tWork has numbers (or blanks) in column Q
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Registered User
    Join Date
    07-07-2011
    Location
    tx
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Comma delimited list cell to new row code help

    Quote Originally Posted by jaslake View Post

    In the file that works, daRow evaluates to 15 and all your coma delimited cells are within that range...so it works. In the file that doesn't work, daRow evaluates to 87 and all the coma delimited cells fall outside that range and aren't getting evaluated.
    Thank you for your answer. How would I get daRow to encompass all of the delimited cells? Really, it needs to be able to encompass a variable amount of rows since they change almost daily, how would you go about accomplishing that? I am pretty new to writing code, so I apologize if that is a silly question. Thanks again for your time.

  5. #5
    Registered User
    Join Date
    07-07-2011
    Location
    tx
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Comma delimited list cell to new row code help

    Quote Originally Posted by mikerickson View Post
    I haven't dug through it in detail, but I notice that the DoesWork workbook has delimited strings in column Q, while Doesn'tWork has numbers (or blanks) in column Q
    The first delimited string is in row #89 in the Doesn't Work column.

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Comma delimited list cell to new row code help

    Hi John
    I've some ideas...I'll post back this afternoon.

  7. #7
    Registered User
    Join Date
    07-07-2011
    Location
    tx
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Comma delimited list cell to new row code help

    Thank you I really appreciate it.

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Comma delimited list cell to new row code help

    Hi John

    This code has been tested on both books and appears do do as you require. This is the code for CountCommas
    Please Login or Register  to view this content.
    And this is the code for InsertRows (you'll see that I changed one line of code)
    Please Login or Register  to view this content.
    Let me know of issues.

  9. #9
    Registered User
    Join Date
    07-07-2011
    Location
    tx
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Comma delimited list cell to new row code help

    That works!! Thank you SO MUCH!!! You really saved my butt.

    Thank you again,
    John

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Comma delimited list cell to new row code help

    You're welcome John...glad I could help.

  11. #11
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Comma delimited list cell to new row code help

    Please Login or Register  to view this content.

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Comma delimited list cell to new row code help

    @mikerickson

    Of course you're right...since I was rewriting that particular part of the code, I should have rewritten it to make it more efficient. Not sure why I didn't...I knew there were better ways. Still learning myself to lead OP's to better solutions...want them to know "what they have works"...but, try this. It's a balance...working on it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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