This works for me
Public Function SumByCellColor(Cellrange As range, Cellcolor As Single) As
Single
Application.Volatile
n = 0
For Each RangeCell In Cellrange
If RangeCell.Interior.ColorIndex = Cellcolor Then
If IsNumeric(RangeCell.Value) Then n = n + RangeCell.Value
End If
Next
SumByCellColor = n
End Function
Also, see
http://www.xldynamic.com/source/xld.ColourCounter.html
--
HTH
RP
"SIGE" wrote in message
om...
Anyone an idea why my function does not work... it seems to unload...
Public Function SumByCellColor(Cellrange As range, Cellcolor As Single) As
Single
Application.Volatile
n = 0
For Each RangeCell In Cellrange
If RangeCell.Interior.ColorIndex = Cellcolor Then
If IsNumeric(RangeCell.Value) Then n = n + RangeCell.Value
End If
Next SumByCellColor = n
End Function
Thx in advance