+ Reply to Thread
Results 1 to 13 of 13

divide by zero error...

  1. #1
    Registered User
    Join Date
    08-20-2009
    Location
    NYC, USA
    MS-Off Ver
    Excel 2007
    Posts
    6

    divide by zero error...

    I am creating a 'weekly average spreadsheet' (Excel 2007) for a teacher. It has a column for each student's name and his test grade for each day (M-F). The last column gives his weekly average.

    She also needs an average for all the students' for the week (vertically). My formula is correct, i.e., =AVERAGE(H2:H11). However, I'm getting a divide by zero error because I have some blank rows above my formula (so she can add new students' names as they come.

    How can I get rid of the divide by zero error so she can see the running averages as she inputs grades (but still leaving empty rows for new names)?

    Thanks so much for your help!

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: divide by zero error...

    how about you ask your "teacher",sounds like a class exercise to me. lol
    if not ,post a workbook with what is wrong,what you have and result you'd expect
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: divide by zero error...

    You only get the error when there are no numbers in the range, so add a check like this

    =IF(COUNT(H2:H11),AVERAGE(H2:H11),"")

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: divide by zero error...

    dadylonglegs
    i must get you to do my homework!!

  5. #5
    Registered User
    Join Date
    08-20-2009
    Location
    NYC, USA
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: divide by zero error...

    Quote Originally Posted by martindwilson View Post
    how about you ask your "teacher",sounds like a class exercise to me. lol
    if not ,post a workbook with what is wrong,what you have and result you'd expect
    Wow, just wow. You really shouldn't assume.

  6. #6
    Registered User
    Join Date
    08-20-2009
    Location
    NYC, USA
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: divide by zero error...

    Quote Originally Posted by daddylonglegs View Post
    You only get the error when there are no numbers in the range, so add a check like this

    =IF(COUNT(H2:H11),AVERAGE(H2:H11),"")
    Thank you for your help - unfortunately, it didn't resolve the issue, but I most definitely appreciate your assistance.

  7. #7
    Registered User
    Join Date
    08-20-2009
    Location
    NYC, USA
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: divide by zero error...

    Quote Originally Posted by martindwilson View Post
    dadylonglegs
    i must get you to do my homework!!
    How rude and presumptuous.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: divide by zero error...

    unfortunately, it didn't resolve the issue,
    That was Martin's point about posting a workbook.
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: divide by zero error...

    yep I'm good at rudeness and presumption but i did qualify by
    if not ,post a workbook with what is wrong,what you have and result you'd expect

  10. #10
    Registered User
    Join Date
    08-20-2009
    Location
    NYC, USA
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: divide by zero error...

    [QUOTE=martindwilson;2150140]yep I'm good at rudeness and presumption but i did qualify by[/QUOT

    Most people would not be proud of those qualities. Do you realize that responses such as yours have a potential 'chilling effect' on people asking future questions? I came to this forum expecting to be helped with a basic Excel question - the purpose of such a forum. I didn't ask the question with the expectation that I would be accused of seeking help with 'homework'. How about you simply ignore my questions in the future?

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: divide by zero error...

    Neutral corners, Gentlemen, please.

  12. #12
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: divide by zero error...

    Quote Originally Posted by doublejoy View Post
    Thank you for your help - unfortunately, it didn't resolve the issue,.....
    Why not? What result did you get with that formula, perhaps I misunderstood your request.....

    Normally AVERAGE function will only give #DIV/0! error if all cells in the range are blank, so my suggested formula is effectively saying "If there are numbers in the range, return the average, otherwise return a blank".

  13. #13
    Registered User
    Join Date
    08-20-2009
    Location
    NYC, USA
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: divide by zero error...

    Quote Originally Posted by daddylonglegs View Post
    Why not? What result did you get with that formula, perhaps I misunderstood your request.....

    Normally AVERAGE function will only give #DIV/0! error if all cells in the range are blank, so my suggested formula is effectively saying "If there are numbers in the range, return the average, otherwise return a blank".
    I actually got a response from another Excel forum that worked. Here it is:

    =IF(COUNT(C2:G2),AVERAGE(C2:G2),"")

    I put this formula in H2 and then dragged it down to the other cells in the column. It gave me each student's average and allowed me to keep blank rows (so she could add/delete students as they come) yet still have a running average at all times. Most importantly, it removed the 'divide by zero' error.

    I really appreciate your help with this and I wish I had explained it a bit clearer. I should have simply stated that I wanted to execute a formula that would accomplish this:

    IF the number in H2 is zero, then leave H2 blank (no divide by zero), but,
    IF the number in H2 is greater than zero, I want Excel to calculate (in H2) the AVERAGE of cells C2:G2


    Thanks, daddylonglegs!

+ 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