View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
mrice mrice is offline
external usenet poster
 
Posts: 1
Default Averages excluding zeros


I suggest using the following user defined function

Function AverageWithOutZeros(DataRange As Range)
For Each Cell In DataRange
If Cell < 0 Then
Total = Total + Cell
Count = Count + 1
End If
Next Cell
If Count < 0 Then
AverageWithOutZeros = Total / Count
Else
AverageWithOutZeros = "#N/A"
End If
End Function

Paste this into a macro sheet and it should then be available on the
insert function menu item.


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=561839