+ Reply to Thread
Results 1 to 7 of 7

Aggregate multiple rows of data to one if conditions are met

  1. #1
    Registered User
    Join Date
    11-28-2018
    Location
    Netherlands
    MS-Off Ver
    Office 13
    Posts
    30

    Aggregate multiple rows of data to one if conditions are met

    Hi gurus,

    I am trying to aggregate raw data based on if Column 4, 9, 26, and 35 are the same values.

    Basically if these columns contain the same values in multiple other rows it means they can be combined into 1 row. When combining, I need to make 2 changes to represent an acurate aggregation of the data. 1st Column 11's new value would be the SUM of all the values in "Volume". And 2nd, Column 13's new value would be a weighted average Price, so (SUMPRODUCT (array 1 = col 11, array 2 = col 13) divided by SUM Col 11). And all other data in the row would stay the same, simply only aggregating these two values and simply deleting the rest, leaving me with one row.

    How can I do this? I am only moderate at VBA and this seems like it needs a scripting dictionary which I am unfamiliar how to build. Would tremendously appreciate anyone's help here.

    Maybe it doesn't need a scripting dictionary, whatever the case I am open to anything to get this done

    A desensitized spreadsheet is attached for your reference, in reality I am dealing with thousands of rows so really need to automate this

    Have a bless day!
    Attached Files Attached Files
    Last edited by stein7; 01-30-2019 at 07:50 AM.

  2. #2
    Registered User
    Join Date
    11-28-2018
    Location
    Netherlands
    MS-Off Ver
    Office 13
    Posts
    30

    Re: Aggregate multiple rows of data to one if conditions are met

    anyone got a clue?

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Aggregate multiple rows of data to one if conditions are met

    Try this:

    Please Login or Register  to view this content.
    Last edited by xladept; 01-30-2019 at 02:53 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Registered User
    Join Date
    11-28-2018
    Location
    Netherlands
    MS-Off Ver
    Office 13
    Posts
    30

    Re: Aggregate multiple rows of data to one if conditions are met

    I can’t thank you enough Xladept. You are awesome. God bless you

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Aggregate multiple rows of data to one if conditions are met

    You're welcome and God Bless You too

  6. #6
    Registered User
    Join Date
    11-28-2018
    Location
    Netherlands
    MS-Off Ver
    Office 13
    Posts
    30

    Red face Re: Aggregate multiple rows of data to one if conditions are met

    Hi xladept, the code you posted for me works great and I am using it daily... I love it so much, now I am trying to implement it on another sheet, with different row/column set up. I tried to make changes but since I am not familiar with scripting dictionaries wasn't able to get it running.

    On the sheet attached, I am trying to aggregate the data based on if column A, C, F, H are the same, and while aggregating SUM column G, and find weighted average in column I, essentially exactly how the other code worked just changing up a find columns and where the data starts...

    Praying you can help me this last time on this
    Attached Files Attached Files

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Aggregate multiple rows of data to one if conditions are met

    I just changed some column numbers - see if it works:

    Please Login or Register  to view this content.

+ 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] Dictionary or Scripting.Dictionary. Binding Referencing Dim-ing. Sub routines and Function
    By Doc.AElstein in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 07-12-2016, 08:28 AM
  2. Cant get data to populate in VBA code from array & scripting dictionary
    By leanne2011 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-25-2015, 04:38 AM
  3. [SOLVED] Using Dictionary in VBA scripting
    By vnzerem in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-04-2014, 02:54 PM
  4. Scripting Dictionary
    By Tendla in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2013, 05:41 AM
  5. [SOLVED] Add multiple items to scripting dictionary from one key and keep structure
    By strud in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-07-2013, 09:44 AM
  6. [SOLVED] Scripting Dictionary
    By thisisgerald in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-18-2012, 01:30 PM
  7. I am using scripting dictionary method -If no data - need a message box -
    By leanne2011 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-03-2012, 07:54 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