Thread: SumByCellColor
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default SumByCellColor

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