View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default SumProduct problem

Function cond_average(a, b, c)
Dim sStr as String
sStr = "Sumproduct(--(" & a.address & _
"=" & b.Address(0,0) & "),--(" & c.address & _
"<""""))"
If Evaluate(sStr) = 0 Then
cond_average = -1
Else
cond_average = Application.SumIf(a, b, c) / _
Application.CountIf(a,b)
End If
End Function


--
Regards,
Tom Ogilvy

"Gil D." wrote in message
ups.com...
Hello,

I call my function like this:
=cond_average(Sheet1!A1:A15,Sheet2!A5,Sheet1!C1:C1 5)

I am using excel XP.

What can be wrong ?

Thank you
Gil D.