View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
carlairis carlairis is offline
external usenet poster
 
Posts: 3
Default formula needed... IF, SUMIF, or SUM ???

Thanks for your reply... but i figure it out by using this..

=AVERAGEIF(C10:C15,"0",C10:C15)

Basically, it ignores the #DIV/0! that I have reference from another
worksheet. Your response was really impressive...

"Billy Liddel" wrote:



"carlairis" wrote:

Here is my data...
2008 B C
January 1.76 3.95
February 2.70 3.36
March 2.22 3.02
April 2.55 2.81
May 3.11 3.19
June #DIV/0!

I'm working on a semiannual performance. Basically I need to sum-up the
data in column C for Jan, Feb, Mar and so on..and then divide this by 6.
But I will not know the data of June until July. So far, I'm using the IF
function but I still get the DIV#0! error... I need the formula to add up
according to the total of months that I have... For instance, in March I will
only need to add up to 3 data value set and divided by 3, but I don't want to
change the formula everymonth. I want a formula that work for 6 months. I
hope someone can help. Thanks!


You can write a UDF to ignore errors. Try this copied into the books vb module

Function FlexAvg(data) As Double
Dim count As Long, mySum As Double, c
For Each c In data
If IsError(c) Then
mySum = mySum
count = count
ElseIf IsNumeric(c) And c 0 Then
mySum = mySum + c
count = count + 1
End If
Next
FlexAvg = mySum / count
End Function

Regards
Peter