+ Reply to Thread
Results 1 to 7 of 7

Combine/Aggregate lines into one where multiple. With common field.

  1. #1
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Combine/Aggregate lines into one where multiple. With common field.

    Hi guys,

    I hope you can help me.

    I have an excel sheet witch has multiple lines for the same job. How can I combine these lines to show a single line per reference, and aggregate the fields with values?

    Example; There are 4 lines for this JobNumber: 201139433

    OnsiteTime TravelTime TravelMiles SLATicks
    INC000167981605 201139433 2014.01.31 2015.12.01 60 120 250 0
    INC000167981605 201139433 2014.01.31 2015.12.07 120 120 250 0
    INC000167981605 201139433 2014.01.31 2015.12.18 60 120 300 0
    INC000167981605 201139433 2014.01.31 2015.12.28 60 120 250 0

    And the idea is to have a single line for these 4 items, with the values of these 4 columns aggregated: OnsiteTime TravelTime TravelMiles SLATicks

    The common denominator for the call is the JobNumber example: 201139433.

    Please see attached example spread sheet.

    Thank you in advance!
    Attached Files Attached Files
    Sharing knowledge, can be likened to taking another person's hand, and pulling them up to a higher level -- onmyway

    If I was helpful, please remember to click on * Add Reputation below

  2. #2
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Combine/Aggregate lines into one where multiple. With common field.

    how you want the values to show,

    One way could be using pivot table.
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    WANT TO SAY THANKS, HIT ADD REPUTATION (*) AT THE BOTTOM LEFT CORNER OF THE POST

    More we learn about excel, more it shows us, how less we know about it.

    for chemistry
    https://www.youtube.com/c/chemistrybyshivaansh

  3. #3
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Combine/Aggregate lines into one where multiple. With common field.

    Hi hemesh. I want it to be in the same format, but all related items combined into a single line. I suppose one would have to create a loop that loops through the data and copy the data to a new sheet?

  4. #4
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Combine/Aggregate lines into one where multiple. With common field.

    I am not good in VBA but solution can be as below
    first follow the below link
    http://www.excelforum.com/tips-and-t...geravatar.html

    copy the code provided
    then open your sheet hit Alt+F11 click insert at the menu bar at the top and click module and paste code

    Then create a new sheet copy paste all column headers and copy all job number and click remove duplicates

    in C2 copy paste below then hold control and shift and then hit enter to make it array formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    drag down and drag to right

    Change red part to your desired flavour may be "-" or "," or something

    I have used char(10) to give it a line break character, after applying formula copy paste as values only and then with all selected click wrap text.

    Hope that helps

  5. #5
    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,613

    Re: Combine/Aggregate lines into one where multiple. With common field.

    Hi onmyway,

    I hope attachement is the same as in duplicated thread I started to answer: www.excelforum.com/showthread.php?t=1127126
    If yes - Try this baby:

    Please Login or Register  to view this content.
    Note that it first sorts on column B to assure all records for one job are listed together, and then for duplicated jobs, mbut firlds with different values it collects all values (marked with exclamation mark). Of course it also fulfills the main task - summation of values in columns P:S
    Best Regards,

    Kaper

  6. #6
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Combine/Aggregate lines into one where multiple. With common field.

    hi hemesh, thanks for the feedback. Although a nice feature, it is not exactly what I want. This simply concatenates everything, where I would like the fields of the matching job numbers to be summed.

  7. #7
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Combine/Aggregate lines into one where multiple. With common field.

    @Kaper i think you are on something! Can you perhaps help to modify the function to sum the values of Columns P:S? Currently it aggregates it like this: ! 19 & 21 & 1. I want a single value, in this case 41.

+ 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. Multiple Lines for one student with one field different. Consolidate to one line
    By LisaOri in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-15-2013, 05:14 AM
  2. Compressing multiple rows down to one row by using a common field
    By feno_uk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-05-2013, 03:11 PM
  3. How to combine data from multiple rows when common column headings exist?
    By pkoury in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-01-2013, 10:43 AM
  4. [SOLVED] How do I combine multiple lines of information into a single cell, separated by commas?
    By ilostar in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-22-2012, 11:48 AM
  5. Combine data onto one row based on common field value
    By jkakareka in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-15-2012, 11:39 AM
  6. Combine Multiple workbooks based on a common column
    By vioStyle in forum Excel General
    Replies: 6
    Last Post: 06-14-2012, 06:44 AM
  7. Merge multiple spreadsheets with common field
    By sbarry50 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-19-2010, 11:42 AM

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