+ Reply to Thread
Results 1 to 15 of 15

Filter Column by Value, if dups Aggregate Rows to 1 Rows

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

    Smile Filter Column by Value, if dups Aggregate Rows to 1 Rows

    Hi everyone,

    I can really use help and appreciate it if anyone has an idea to the following

    I am working with a spreadsheet that is raw data from a system, I need to aggregate rows of data if a condition is met.

    Bassically, while filtering for dups, if it finds rows that are the same it would.
    [1] SUM column E, display only the summed quantity in the new row.
    [2] Column H, it would display the weighted average Value only.... To do this it would have to take SUMPRODUCT of (Column G x Column H) divided by SUM col E
    Attached Files Attached Files
    Last edited by stein7; 01-29-2019 at 12:07 AM.

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

    Re: Filter Column by Value, if dups Aggregate Rows to 1 Rows

    Cannot do the weighted Average since no data in "G" - But this will get you the aggregate of all records with ID's:
    Be sure to have backup before using
    Please Login or Register  to view this content.
    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

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

    Re: Filter Column by Value, if dups Aggregate Rows to 1 Rows

    Wow thank you so much xladept! But I was wondering I need to do the weighted average, I meant to write column E this is where the Order Size is.... So I would need to be able to do SUMPRODUCT (col E, col H) / SUM col E ...
    Last edited by stein7; 01-27-2019 at 03:30 PM.

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

    Re: Filter Column by Value, if dups Aggregate Rows to 1 Rows

    Probably another column to aggregate the Total Price then another scan after the aggregates to get the average price.

  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: Filter Column by Value, if dups Aggregate Rows to 1 Rows

    This uses G and AH for Average Price:

    Please Login or Register  to view this content.

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

    Re: Filter Column by Value, if dups Aggregate Rows to 1 Rows

    Hi xladept, I can't thank you enough for showing me this. This is a really great way of doing it and really fast. I do want to mention the one flaw I need to figure out to make this work 100%. Right now it is not taking into account that if Column AH is blank, we want to keep this row, and only aggregate those with dups.... It is deleting rows where AH is blank.
    Last edited by stein7; 01-27-2019 at 03:31 PM.

  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: Filter Column by Value, if dups Aggregate Rows to 1 Rows

    Now try this:

    Please Login or Register  to view this content.

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

    Re: Filter Column by Value, if dups Aggregate Rows to 1 Rows

    This is amazing stuff, you rock. I can't thank you enough. :D

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

    Re: Filter Column by Value, if dups Aggregate Rows to 1 Rows

    You're welcome and thanks for the rep!

  10. #10
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Filter Column by Value, if dups Aggregate Rows to 1 Rows

    @ xladept,

    I like, WOW!
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

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

    Re: Filter Column by Value, if dups Aggregate Rows to 1 Rows

    @ Winon - Thanks, I copied the input 15 times and found out about using CurrentRegion when the input was filled with blanks

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

    Re: Filter Column by Value, if dups Aggregate Rows to 1 Rows

    Hi xladept, I implemented this on my real data set and I realized that the columns weren't positioned entirely right from my sample you worked on. Usually this isn't an issue as I would change it myself, however Col 7 which is the blank column in the sample you were putting (price x quantity) actually has data, so I tried replacing 7 int he code to 36 with hopes of shifting this calculation out of the way, but when I do this the code breaks, I can't figure out why... All the other changes to columns I did work just this one. Would be awesome to get your input I am sure it takes 2secs as all the heavy lifting is done...

    A new sample sheet is attached with the right columns in the right spots as my real data.

    Bassically here are the changes that you will see in the sample sheet:
    Parent Order ID: code references column 33 in reality should reference column 34
    Quantity: code references column 5 in reality should reference column 11
    Column 34 where you put the calculated weighted average price, I pushed it over to 35 since Order ID is there
    ---
    to date all these changes work besides this last one:
    Column 7: you used it in the code to put a calculation, in reality the dataset has a description there, I replaced col 7 for col 36 in your code and code doesnt work

    Any way you can kindly suggest how I can implement your code to the enwly attached spreadsheet?
    Last edited by stein7; 01-28-2019 at 07:28 PM.

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

    Re: Filter Column by Value, if dups Aggregate Rows to 1 Rows

    Try this:

    Please Login or Register  to view this content.
    Last edited by xladept; 01-28-2019 at 11:28 PM.

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

    Re: Filter Column by Value, if dups Aggregate Rows to 1 Rows

    Ah man I really wish I double checked what I uploaded. I see you changed it to column 5 now, essentially this gives me the same problem, im sure its one little tweak and were good to go but if you check now the spreadsheet you will see that there is data in col 5 too. The reason some columns were blank was because I was desensitizing it and removing data, essentially any extra calculations we do with the macro needs to be after column 35, or else its overwritting data (price and volume is okay though since we want to overwrite that).

    I know I am starting to grind your gears, but would really appreciate it if you had a last look at the ammendmend I just did,the code breaks in the same spot and I am busting my head trying to figure out why... Sorry I didn't explain so well the first time, if you check the sample sheet now it will be clear.

    I changed 5 to 37 and the column for price... and it won't work
    Please Login or Register  to view this content.
    Last edited by stein7; 01-29-2019 at 12:22 AM.

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

    Re: Filter Column by Value, if dups Aggregate Rows to 1 Rows

    Adding the new columns at the end required that we initialize them in order to establish the array bounds - try this:

    Please Login or Register  to view this content.
    Last edited by xladept; 01-29-2019 at 12:49 PM.

+ 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] Aggregate Rows of Data if Condition is met (if 2 Columns contains dup values)
    By popcorn7 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 09-28-2018, 10:27 AM
  2. [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
  3. [SOLVED] Aggregate results from multiple rows
    By Kyba in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-26-2017, 08:52 AM
  4. Aggregate function to number rows
    By cdumper in forum Excel General
    Replies: 9
    Last Post: 09-27-2014, 07:22 PM
  5. [SOLVED] Insert Blank Rows between existing data based on dups in sheet2
    By Melissa Camp in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-29-2014, 07:07 AM
  6. [SOLVED] Need multiple duplicate rows summed into one row for each product/version, delete dups
    By gereckes in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-03-2014, 04:33 PM
  7. multiple rows with some dups where I need result on one line
    By VAN GOGH in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-26-2006, 06:50 PM

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