+ Reply to Thread
Results 1 to 4 of 4

Multiple Averages by Groups

  1. #1
    Registered User
    Join Date
    10-27-2009
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    2

    Multiple Averages by Groups

    Hi guys, I'm new to the forum so please bear with me. I am familiar with excel but I would by no means cal myself an expert. I am currently working on a spreadsheet with over 3000 data entries, so I need to create a macro as a huge time saver. What I need to do is extract averages from a set of values, but I have groups that vary by size. The data is first broken down into groups of 8 (1a_1_0...) and then by tree species. I need to crank out average BA for each tree species in each group. This table is an example of what I am looking to do

    Transect_P Tree_Spec Basal Area Mean BA
    1a_1_0 Pr se 44.17860938 47.22202469
    1a_1_0 Pr se 50.26544
    1a_1_0 Th oc 78.53975 159.4684174
    1a_1_0 Th oc 132.7321775
    1a_1_0 Th oc 153.93791
    1a_1_0 Th oc 201.06176
    1a_1_0 Th oc 176.7144375
    1a_1_0 Th oc 213.8244694
    1a_1_50 Th oc 78.53975 60.08290875
    1a_1_50 Th oc 44.17860938
    1a_1_50 Th oc 86.59007438
    1a_1_50 Th oc 28.27431
    1a_1_50 Th oc 95.0330975
    1a_1_50 Th oc 86.59007438
    1a_1_50 Th oc 33.18304438
    1a_1_50 Th oc 28.27431
    1a_2_0 Fr am 324.2925127 324.2925127
    1a_2_0 Ma sy 993.1458202 993.1458202
    1a_2_0 Th oc 214.0837291 328.9373273
    1a_2_0 Th oc 506.7070511
    1a_2_0 Th oc 45.6036346
    1a_2_0 Th oc 153.278883
    1a_2_0 Th oc 729.6581536
    1a_2_0 Th oc 324.2925127

    I am just looking for ideas to make this go much much faster. Thanks in advance guys. I uploaded these values in an attachment as well. Apologies for the bad formatting.
    Attached Files Attached Files
    Last edited by icytea_thunder; 10-28-2009 at 12:16 AM. Reason: Table Format Apologies

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Multiple Averages by Groups

    Put this in D2 and drag down.
    =SUMPRODUCT(-($A$2:$A$25=$A2)*($B$2:$B$25=$B2),$C$2:$C$25) / SUMPRODUCT(--($A$2:$A$25=$A2)*($B$2:$B$25=$B2))
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    10-27-2009
    Location
    NY
    MS-Off Ver
    Excel 2003
    Posts
    2

    Talking Re: Multiple Averages by Groups

    Thanks Mike. That worked great with some tweaking to match final use. Never would have figured that one out.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Multiple Averages by Groups

    Just on an aside - have you considered using a Pivot Table for your analysis ?

    With Transect_P & Tree_Spec as ROW Fields and Basal Area set as DATA Field (set to AVERAGE)

    Pivot Tables will give you a lot of reporting flexibility for little / no effort.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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