+ Reply to Thread
Results 1 to 4 of 4

averageifs over several ranges

  1. #1
    Registered User
    Join Date
    07-28-2009
    Location
    Seattle
    MS-Off Ver
    Excel Mac 2011
    Posts
    38

    averageifs over several ranges

    Hello,
    I want to get the average of numerical values in 3 ranges , eg A2:A15, A20:A30, A35:A45, ">0". The intervening cells contain other data, so the ranges are not contiguous. I think AVERAGEIFS is the function to use.
    I have found my way through nested IF and other functions so am reasonable able to trouble shoot a function . But have not been able to solve this one, would appreciate help
    phstol
    Last edited by phstol; 08-06-2009 at 02:45 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: averageifs over several ranges

    I am assuming that the data in between is numeric? Because it it test then you can include them in the range and get correct results...

    e.g =AVERAGEIF(A2:A45,"<>0")

    Otherwise, try:

    =SUM(SUMIF(INDIRECT({"A2:A15","A20:A30","A35:A45"}),"<>0"))/SUM(COUNTIF(INDIRECT({"A2:A15","A20:A30","A35:A45"}),"<>0"))
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    07-28-2009
    Location
    Seattle
    MS-Off Ver
    Excel Mac 2011
    Posts
    38

    Re: averageifs over several ranges

    Thanks so much for yr speedy reply. I couldn't get your solution to work, even after much messing with the format of the string.
    But it gave me the clue......
    I used SUMIF(A2:A15,">0")+SUMIF(A20:A30,">0")+SUMIF(A35:A45,">0")/COUNTIF(A2:A15,">0")+COUNTIF(A20:A30,">0")+COUNTIF(A35:A45,">0").
    THis gives me the average numeric value for only cells with a >0 value.

    I found the above works with or without the additional "SUM" as in: SUM(SUMIF(...../SUM(COUNTIF(....

    THis solution seems clumsy compared to yurs so if you have any comments on editing yours to make it work I'd appreciate it.

    REf the INDIRECT, I had not come across this before. I don't understand from Excel's Help how it is different or better than "anchoring" cell locations using $. Wd appreciate your insight on this.

    Anyway, I usually don't anchor the cells while building a complicated spreadsheet because I'm adding /deleting and moving things around , and prefer to let Excel keep track of cells sliding around during development.
    Much appreciate your help

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: averageifs over several ranges

    I guess for the three ranges you have, your way is just as good... but my formula allows you to add more ranges with making the formula too large..

    The Indirect() method here is used as to trick Excel into getting SUMIF() to evaluate each range independently against the same criteria. Then the SUM() adds the 3 results as your formula did.

    My formula also uses criteria <>0 wheras you use >0... might be different based on your data...

    Should have worked as yours did...

+ 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