+ Reply to Thread
Results 1 to 4 of 4

Script to create averages of subgroups of rows, depending on content of rows

  1. #1
    Registered User
    Join Date
    10-24-2016
    Location
    UK
    MS-Off Ver
    2010
    Posts
    3

    Script to create averages of subgroups of rows, depending on content of rows

    Hello,

    I have a dataset which requires averages to be taken of values in one column, for subsets of rows which share the same values in the other rows. E.g. for all cases where columns A, B, and C match on values, take the average of values in column D.

    I would like advice on how to approach this. Would using a script be better? Or trying something using a pivot table perhaps?

    In the example attached, I have simply used =AVERAGE() to calculate the average of specified sets of cells in column D. However, in my real dataset (the attached is a simplified example aimed to show what I need to learn to do) there are many thousands of rows, so this would be far from an efficient approach.

    I am not sure what approach to take with this problem so would appreciate suggestions for methods to use.

    Previously (long time ago!) with a somewhat different dataset, I had a script which generated a new sheet which gave one row for each possible combination of the first columns, and then an average for the final column (averaging all cases where the rows in the original sheet matched) but I cannot remember how / what exactly I did to do that.
    Attached Files Attached Files
    Last edited by LennaKB; 10-26-2016 at 09:25 AM. Reason: Returned to add details as ran out of time when creating the thread

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,614

    Re: Script to create averages of subgroups of rows, depending on content of rows

    Nothing is more frustrating than to be working on homework and to get stuck. Without guidance, you might have no hope of finishing the assignment before the deadline. The Internet can be a big help in that respect, but without learning how to get the right answer, asking others to solve your homework questions for you simply becomes a downward spiral (and it's cheating).

    We do not want to contribute to you cheating yourself out of your education, but we also acknowledge that seeking assistance to learn a concept is a legitimate request.

    If you are genuinely interested in receiving help in the form of tutoring or coaching, then please rephrase the title of your original post to clearly indicate you are seeking coaching or tutoring help. Any forum members (who are willing to assist as a tutor) will modify their responses accordingly to facilitate your learning. Tutors don't tell you the answers, they help you figure it out for yourself; so don't expect answers, expect suggestions, or just plain hints. Also, be specific in describing the function/formula or technique you trying to learn, and tell us what you have attempted so far. Otherwise, expect your plea for homework answers to be ignored.
    Last edited by protonLeah; 10-25-2016 at 06:34 PM.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    10-24-2016
    Location
    UK
    MS-Off Ver
    2010
    Posts
    3

    Re: Script to create averages of subgroups of rows, depending on content of rows

    Quote Originally Posted by protonLeah View Post
    Nothing is more frustrating than to be working on homework and to get stuck. Without guidance, you might have no hope of finishing the assignment before the deadline. The Internet can be a big help in that respect, but without learning how to get the right answer, asking others to solve your homework questions for you simply becomes a downward spiral (and it's cheating).

    We do not want to contribute to you cheating yourself out of your education, but we also acknowledge that seeking assistance to learn a concept is a legitimate request.

    If you are genuinely interested in receiving help in the form of tutoring or coaching, then please rephrase the title of your original post to clearly indicate you are seeking coaching or tutoring help. Any forum members (who are willing to assist as a tutor) will modify their responses accordingly to facilitate your learning. Tutors don't tell you the answers, they help you figure it out for yourself; so don't expect answers, expect suggestions, or just plain hints. Also, be specific in describing the function/formula or technique you trying to learn, and tell us what you have attempted so far. Otherwise, expect your plea for homework answers to be ignored.
    Oh how I wish that this was a homework question. If it were, I'd probably have some idea of what I actually needed to use/consider.

    I have just added a little more detail to the question description but cannot see at present how to edit the title.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,526

    Re: Script to create averages of subgroups of rows, depending on content of rows

    Try
    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. Replies: 1
    Last Post: 09-06-2016, 08:40 AM
  2. Selecting rows depending on content
    By alex_boothby in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-21-2015, 09:03 AM
  3. Copy specific rows to another tab depending on content.
    By Jeffro2p in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2014, 04:54 PM
  4. How to delete rows depending on cell content
    By grim72 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-27-2014, 11:51 AM
  5. Adding Multiple Rows Depending on Column Content
    By ryanb4614 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-24-2014, 09:58 AM
  6. [SOLVED] Programmatically Sorte Rows that are Arranged in Subgroups.
    By code_hungry in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2005, 08:05 PM
  7. Hide rows depending on content...
    By Gord in forum Excel General
    Replies: 1
    Last Post: 05-12-2005, 05:06 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