+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    01-08-2010
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    18

    Averaging and ignoring non-numbers when not in a range

    Hi everyone,

    Thanks in advance for all help on this, because these forums have never let me down before, and I've always found the posters to be first rate.

    My spreadsheet lists numbers in every row, but I need a formula that will average only every 5th number. That's not a problem on its own, since I can manually select the cells and it will average them.

    The problem comes when some of those cells do not contain a number. Some are blank, and some have an IF formula that causes them to say "N/A". I tried to put in an IF(ISNUMBER) formula but Excel didn't like me selecting individual cells instead of a range.

    I'm looking for a formula that will allow me to average every 5th number, while excluding empty cells and cells that say "N/A", and, if there are no cells containing numbers to average, for it to say "N/A".

    Can anyone help me with this? I can provide example spreadsheets if further clarification of what I mean is necessary.
    Last edited by rachelar; 03-16-2010 at 08:13 AM.

  2. #2
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Averaging and ignoring non-numbers when not in a range

    Perhaps

    =IFERROR(AVERAGE(IF((MOD(ROW($A$1:$A$100)-ROW($A$1),4)=0)*ISNUMBER($A$1:$A$100),$A$1:$A$100)),"N/A")
    confirmed with CTRL + SHIFT + ENTER

    where A1:A100 contain data points and average is of A1, A5, A9 etc...) - adjust as nec.

    (If the above is not what you want I would suggest posting a sample file outlining setup and desired results based on sample data)

  3. #3
    Forum Guru rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Averaging and ignoring non-numbers when not in a range

    here an alternative
    HTML Code:
    =AVERAGE(IF(--(ISNUMBER(A1:A25))*--(MOD(ROW(A1:A25),5)=0),A1:A25))
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  4. #4
    Registered User
    Join Date
    01-08-2010
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Averaging and ignoring non-numbers when not in a range

    Hi DonkeyOte and rwgreitveld,

    Strangely enough I noticed the little reputation scales in the corner of posts this morning, and went back and clicked on those for you both for posting in my last threads. Thanks

    I've never used array formulas before and not entirely sure what to do with it (in terms of altering it), so here's a sample file.

    Cells D23, D24 and D25 are fine, because the formula automatically ignores empty cells. The problem arises with cells E23, E24 and E25, because there are no numbers for those formulae to average. I just want them to say "N/A".

    It would also be very nice to know a shortcut to average every other/3rd/so on cell in a column instead of manually selecting every cell! This is something I have to do a lot and is very time consuming.

    Thanks guys.
    Attached Files Attached Files

  5. #5
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Averaging and ignoring non-numbers when not in a range

    Given use of XL2007 and having now seen your file - perhaps:

    C23: =IF(SUMIF($B$3:$B$21,"Offer",C$2:C$20),AVERAGEIF($B$3:$B$21,"Offer",C$2:C$20),"N/A")
    copied across to E23 (use of 3:21/2:20 is deliberate)

    C24:
    =IF(SUMIF($B$2:$B$21,"Variance",C$2:C$21),AVERAGEIF($B$2:$B$21,"Variance",C$2:C$21),"N/A")
    copied across to E24

    C24:E24 copied to C25:E25 but change "Variance" to "Difference due to quote"

  6. #6
    Registered User
    Join Date
    01-08-2010
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Averaging and ignoring non-numbers when not in a range

    Quote Originally Posted by DonkeyOte View Post
    Given use of XL2007 and having now seen your file - perhaps:

    C23: =IF(SUMIF($B$3:$B$21,"Offer",C$2:C$20),AVERAGEIF($B$3:$B$21,"Offer",C$2:C$20),"N/A")
    copied across to E23 (use of 3:21/2:20 is deliberate)

    C24:
    =IF(SUMIF($B$2:$B$21,"Variance",C$2:C$21),AVERAGEIF($B$2:$B$21,"Variance",C$2:C$21),"N/A")
    copied across to E24

    C24:E24 copied to C25:E25 but change "Variance" to "Difference due to quote"
    Thanks DonkeyOte, this seems to work.

    I do have one question though: when I enter the formula into D25 (making the necessary alteration) I get a different total to the one I get when I manually average the relevant cells. It's the same total as I get in D24 (which I'm pretty sure is correct, from manual averaging again). Why is that?

  7. #7
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Averaging and ignoring non-numbers when not in a range

    Quote Originally Posted by rachelar
    I do have one question though: when I enter the formula into D25 (making the necessary alteration) I get a different total to the one I get when I manually average the relevant cells.
    Did you change both references to "Variance" ?
    The correct formula would generate £19.50


    On aside please don't quote posts in full - clutters the board - use the New Post / Quick Reply or quote only those parts necessary for your subsequent post to make sense

  8. #8
    Registered User
    Join Date
    01-08-2010
    Location
    Wales
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Averaging and ignoring non-numbers when not in a range

    Quote Originally Posted by DonkeyOte View Post
    Did you change both references to "Variance" ?
    The correct formula would generate £19.50
    No I didn't, thanks for spotting that. The formula seems to work fine, then, I'll pop it into the full spreadsheet. Thanks for all your work.

    On aside please don't quote posts in full - clutters the board - use the New Post / Quick Reply or quote only those parts necessary for your subsequent post to make sense
    Sorry

    Just to check, is there a shortcut to average every other/5th/etc row in a range, not worrying about ignoring errors and blank cells?
    Last edited by rachelar; 03-16-2010 at 08:07 AM.

  9. #9
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Averaging and ignoring non-numbers when not in a range

    If you can, use AVERAGEIF(S) ... this is viable here because the items to Average have common denotation and you're running XL2007.

    Pre XL2007 then if the denotation holds true use SUMIF/COUNTIF ... if that's not the case then the "simplest" single cell solution is to use a MOD based Array as previously outlined.
    Last edited by DonkeyOte; 03-16-2010 at 09:07 AM. Reason: added SUMIF/COUNTIF point

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.2.0