+ Reply to Thread
Results 1 to 9 of 9

Combine data from multiple rows into one row when other column data changes

  1. #1
    Registered User
    Join Date
    11-15-2012
    Location
    131is astlood
    MS-Off Ver
    Excel 2007
    Posts
    5

    Combine data from multiple rows into one row when other column data changes

    Hi,

    I have a large spreadsheet of customers and their program data. Many customers have more than one program. Each program is on a separate row with the customer's information being repeated for each row.

    The attached example (sheet1) shows one set of data in it's existing form with one row of customer information for each program they have, whether it is one program or more.

    The next set of data on the same attachment (sheet2) shows what I would like to be my resulting data. That being, each customer having one row of data and their program or programs in one cell of the customer's row of information. Multiple programs would be separated with a comma and listed in this order: CW,CF,MC.

    I used celebrity names in my sample worksheet, just for fun.

    Any help would be greatly appreciated!

    Sample Worksheet.xlsx

  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: Combine data from multiple rows into one row when other column data changes

    Try this:

    Please Login or Register  to view this content.
    _________________
    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
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Combine data from multiple rows into one row when other column data changes

    My approach is a little bit different, but at least it doesn't limited to only CW, CF and MC.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by JieJenn; 11-16-2012 at 02:17 PM. Reason: The line Columns(9).clearcontents should be .Columns("I:M").Delete

  4. #4
    Registered User
    Join Date
    11-15-2012
    Location
    131is astlood
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Combine data from multiple rows into one row when other column data changes

    It's perfect. Thank You Sooooo much!

  5. #5
    Registered User
    Join Date
    11-15-2012
    Location
    131is astlood
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Combine data from multiple rows into one row when other column data changes

    Hello Again,

    I have the same spreadsheet of customers and their program data and need an adjustment to the code previously provided. As stated many customers have more than one program and each program may also have different renewal months. Each program is on a separate row with the customer's information being repeated for each row.

    The attached example (sheet1) shows one set of data in it's existing form with one row of customer information for each program they have, whether it is one program or more.

    The next set of data on the same attachment (sheet2) shows what I would like to be my resulting data. That being, each customer having one row of data and their program or programs in one cell of the customer's row of information. Multiple programs would be separated with a comma and listed in this order: CW,FS,MC. Multiple renewal months would also be separated with a comma and in the order they were originally in by program. If all renewal months are the same for all programs in each customer record then only one month would show in the Renewal column after the rows are merged.

    The help I received last time was a time/life saver. I hope someone can crack this one too.

    Thank You!
    Attached Files Attached Files

  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: Combine data from multiple rows into one row when other column data changes

    My macro with the tweaks needed. Notice the "formula" line of code, that is where you edit the codes listed and the order they are in, the codes are put into that order. You can add more if needed within that formula.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-15-2012
    Location
    131is astlood
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Combine data from multiple rows into one row when other column data changes

    JBeaucaire thank you so much for your help. The code works but seems to have a small glitch. If we can get that fixed it would be perfect.

    For customers who have different programs but all the programs have the same renewal months in the "Renewal" column it would be great if it would just show that one renewal month instead of two identical dates divided by the comma.

    For example: Pamela Anderson has two programs and they both have a renewal of 7/31/2013. With this code shows the renewal column for Pamela as "7/31/2013, 7/31/2013" instead of only "7/31/2013" since both programs have the same date.

    Is that possible to do?

    Thanks Again

  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: Combine data from multiple rows into one row when other column data changes

    Yes, but I believe the results would be nonsensical after that. If some codes renew in the same months and others do not, you would end up with a concatenated list that was no longer clear which date goes with each code. 2 codes and 1 date, not problem. But 3 codes and 2 dates.... odd. I would suggest you leave it as is.

  9. #9
    Registered User
    Join Date
    11-15-2012
    Location
    131is astlood
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Combine data from multiple rows into one row when other column data changes

    That sounds ligical. However, I also want to use the data to identify when different programs for the same customer have different renewal months. In this case I wouldn't really care which renewal goes with what program only that there are different renewal months for the same customer. So I can use the first code for my main purpose and if you are able to do the other tweak I can use that code for my second purpose. That would make it easier. Again, thank so much for all your help .

+ Reply to 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