Results 1 to 4 of 4
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,470
    Thanks
    30
    Thanked 62 Times in 58 Posts

    Avg non-zero values (2002)

    I need to perform an average over a set of data (in many, many places throughout a spreadsheet). However, I only want the average of the non-zero values (don't want the 0s to be counted in the average). Rather than constantly test and weed out those values, would it be logical to have a user-defined function or some VBA macro that would handle this? Maybe something called: AVGNO ??

    Seems logical to me, but I don't know how to write it, or what the best approach would be...would appreciate any help.

    Thanks in advance.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Avg non-zero values (2002)

    You can use an array formula for this - confirm with Ctrl+Shift+Enter instead of just Enter. Say that you want to average the values in A1:A100 that are not 0:
    <code>
    =AVERAGE(IF(A1:A100<>0,A1:A100))
    </code>
    Blanks, zeros and text values will be ignored.

  3. #3
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Avg non-zero values (2002)

    Hans: The original post said that the values are "(in many, many places throughout a spreadsheet)." If that is correct, and the values are not in contiguous cells, an array formula is going to be tough.
    Legare Coleman

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Avg non-zero values (2002)

    Oops, I didn't read carefully enough.

    But I think KWeaver will have to provide more information before we can offer further help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •