+ Reply to Thread
Results 1 to 19 of 19

Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

  1. #1
    Registered User
    Join Date
    09-21-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    18

    Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    Hi guys,

    I am trying to get a macro to run that will aggregate Rows of data based on if 2 columns contain the same value. I know the best way is to use Pivot Tables, but I absolutely can't use a pivot table, this data needs to be aggregated no pivot table as other macros will import it somewhere. Fyi real spreadsheet has 1000's of rows so can't do manually.

    I have attached a spreadsheet for your reference.

    Basically, the conditions to aggregate the data is:

    If Column I & Column W are the same values as another Rows Column I & W, I would like to aggregate those rows to one line, while doing so summing K (the only value that changes among the Rows).

    The output should give this result in 3 lines under the headers. (aggregating John's order and Abe's order)

    Customer Booked {...} all other data is the same copy paste
    JOHN1234 2 {...}
    ALAIN1234 5 {...}
    ABE1234 6 {...}

    Would really appreciate any help I can get, been at this for a couple days. Everything I can find directs me to Pivot tables but I can't do it that way. Thank you!
    Last edited by AliGW; 10-27-2018 at 02:41 AM. Reason: Spreadsheet remoived as requested by OP - sensitive data therein.

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,335

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    Hi popcorn7

    JOHN1234 2 {...}
    ALAIN1234 5 {...}
    ABE1234 6 {...}
    This seems incorrect...The red part ...Rows 4 to 7 have same values in F & W
    Or must it be I & W
    Last edited by sintek; 09-26-2018 at 12:13 PM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    09-21-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    18

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    Yes apologies, it is indeed column "I" that I am going by. I will edit post. Any help is greatly appreciated

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,335

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    Perhaps this...
    Results as follows...
    JOHN1234 2
    ALAIN1234 4
    ABE1234 8
    Please Login or Register  to view this content.
    Last edited by sintek; 09-26-2018 at 01:53 PM.

  5. #5
    Registered User
    Join Date
    09-21-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    18

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    wow that's a very impressive code, thank you so much!

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,335

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    Only if it works with your actual dataset...
    Thanks.gif
    Last edited by sintek; 09-26-2018 at 02:50 PM.

  7. #7
    Registered User
    Join Date
    09-21-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    18

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    Hey sintek, my actual dataset the Sheet is named "Database" when I change Sheet1 in your code to Database it doesn't work. I also tried writting it Sheets("Database"). I don't see how I can get it modified can you kindly help me out - this should be straight forward.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,335

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    can you kindly help me out
    Sure I can ... if I had a file to work with...

  9. #9
    Registered User
    Join Date
    09-21-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    18

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    Yes apologies. It is back. Really appreciate it sintek

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,335

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    Code works fine...
    Please Login or Register  to view this content.
    See result after code ran in upload...

    Edit...slight change to code...

    Please Login or Register  to view this content.
    Last edited by AliGW; 10-27-2018 at 02:41 AM. Reason: Spreadsheet remoived as requested by OP - sensitive data therein.

  11. #11
    Registered User
    Join Date
    09-21-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    18

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    Hi sintek, I haven't answered you because I have been working on this on my actual data set for a day now and I am still having issues applying it. Your method of doing this is really great, I would like to go by it.

    Your code bugs out because when we filter by Client like ALAIN1234, there is in reality many different Order ID's for him, not just one Order ID to aggregate. So I am looking to aggregate each of his orders. I would really appreciate it if you had a look again with this Sample Spreadsheet attached. As it stands it could only be a little edit. I am reaching out to you on last effort, as I said I been at it for a day now and can't get it, my VBA skills aren't your level.

    Little Recap what I am trying to do...Basically I am trying to filter by Col I "Client", and again for Col W, aggregating Col K for each Order ID that is the same.

    Really appreciate your time
    Last edited by popcorn7; 09-27-2018 at 12:20 PM.

  12. #12
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,335

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    Upload has no ALAIN1234

  13. #13
    Registered User
    Join Date
    09-21-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    18

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    I changed the names, the ALAIN1234 was a desensitized name anyways. We can go with the names there now in the upload anyways, it won't change anything. thank you so much for looking at this, I am too still trying to edit

  14. #14
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,335

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    A bit more complex than we both anticipated lol....Try this...

    Please Login or Register  to view this content.
    Last edited by sintek; 09-28-2018 at 02:22 AM.

  15. #15
    Registered User
    Join Date
    09-21-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    18

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    Sintek I can't thank you enough, you are a hero! Really appreciate it

  16. #16
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,335

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    Is it finally PERFECT...

  17. #17
    Registered User
    Join Date
    09-21-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    18

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    Hi Sintek,

    View my private msg regarding the updates. We are so close. :O Having an issue when there is a Client with 1 order only. Updated Sample Sheet, problem occurs with TROUBLE1234
    Last edited by popcorn7; 09-28-2018 at 09:05 AM.

  18. #18
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,335

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    Caught me just in time...Away for 2 weeks...

    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    09-21-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    18

    Re: Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)

    Thnak you so much for your help here, I wish you all the best. Have a great time off/travels All the best to you, can't thank you enough

+ 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. [SOLVED] Loop to scan data and aggregate Rows that are the same
    By lougs7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2018, 06:48 PM
  2. Aggregate function with condition
    By buttonman in forum Excel General
    Replies: 9
    Last Post: 06-30-2017, 02:23 PM
  3. [SOLVED] Aggregate values in columns based on a cell identifier
    By bjarmeister in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-30-2015, 03:33 AM
  4. Aggregate data / remove empty columns
    By patapsco59 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-17-2014, 11:25 AM
  5. Aggregate data in a range of columns to remove blank cells
    By arbgd1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-05-2013, 04:11 PM
  6. Replies: 3
    Last Post: 11-19-2010, 06:26 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