+ Reply to Thread
Results 1 to 8 of 8

calculate average - range depends on another field

  1. #1
    Registered User
    Join Date
    09-19-2012
    Location
    Hawaii
    MS-Off Ver
    Excel 2010
    Posts
    9

    calculate average - range depends on another field

    Hello everyone,

    I have to calculate averages and the range changes. For example, John (workshop facilitator) had 6 attendees so he has six rows, one for each attendee; Jennifer (workshop facilitator) had two attendees so she has two rows, one for each attendee.
    To add to the complexity, there are six columns of scores for each that needs to be averaged (six calculations per facilitator).
    Finally, I need to know how many attendees were involved (i.e., the number of rows for that facilitator).
    The goal is to have a worksheet where each facilitator has his/her row, the columns give the facilitator's average scores, and the last column says how many attendees.

    I attached a sample file with the before and desired after worksheet.

    I have hundreds of rows and doing this manually via pivot table will definitely cause errors so any help you can give so it's automated, will be greatly appreciated!

    Thank you!
    Monica
    Attached Files Attached Files

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: calculate average - range depends on another field

    You can put this formula in cell B2 of the After sheet:

    =AVERAGEIF(Before!$A:$A,$A2,Before!C:C)

    Copy across to G2, then copy those formulae down. Use this formula in H2:

    =COUNTIF(Before!A:A,A2)

    then copy down.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    09-19-2012
    Location
    Hawaii
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: calculate average - range depends on another field

    Thank you Pete.

    I made these changes (added the Sheet name 'Before' to each variable) and I got the formulas to work:
    =AVERAGEIF(Before!$A:$A,Before!$A2,Before!C:C)
    =COUNTIF(Before!A:A,Before!A2)

    To finish, I will
    1) copy the names from 'Before' column A to the new 'After' sheet.
    2) copy and paste special > values to remove the formula
    3) remove duplicates.

    Done.

    Thank you. This will save me much time.

    --Monica

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: calculate average - range depends on another field

    Glad to be able to help.

    If that takes care of your original question, please select Thread Tools from the menu above your first post and mark this thread as SOLVED.

    Also, since you are relatively new to the forum (in terms of posts), you might like to know that you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of a post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete

  5. #5
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: calculate average - range depends on another field

    More time saving

    Please Login or Register  to view this content.
    Kind regards
    Leo
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    09-19-2012
    Location
    Hawaii
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: calculate average - range depends on another field

    Leo,

    You are awesome -- it's a one click solution! Worked perfectly. I cannot thank you enough for sharing this code with me.

    --Monica

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: calculate average - range depends on another field

    Since I made it already I'll post it anyway.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  8. #8
    Registered User
    Join Date
    09-19-2012
    Location
    Hawaii
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: calculate average - range depends on another field

    Thanks for posting it -- I learn when I see different approaches and different solutions. So I'm glad to see your post.

    Enjoy the day,
    Monica

+ 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. Average won't calculate off of sourced field
    By hwishman in forum Excel General
    Replies: 11
    Last Post: 09-11-2015, 03:03 PM
  2. [SOLVED] Need vba code to make sum and average of row depends upon unique names in col A
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-02-2015, 02:54 AM
  3. calculate the sum of part used depends upon end of serial no
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-08-2014, 02:37 PM
  4. [SOLVED] calculate average for all of data field using GETPIVOTDATA?
    By andrew in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-30-2012, 08:48 PM
  5. Replies: 3
    Last Post: 03-03-2012, 12:16 PM
  6. Replies: 2
    Last Post: 10-06-2010, 02:40 PM
  7. Input range only and calculate Average of that range in another cell
    By Kokomo in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-27-2007, 09:35 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