You should be using Double not Long as your numbers are not whole numbers. You also need to make the function volatile, and it's better not to pass the cell the function is in as an argument:
Function SumByColor(CellColor As Range, rRange As Range) As Double
Dim cSum As Double
Dim ColIndex As Integer
Application.Volatile True
ColIndex = CellColor.Interior.ColorIndex
For Each cl In rRange
If cl.Interior.ColorIndex = ColIndex Then
cSum = WorksheetFunction.Sum(cl, cSum)
End If
Next cl
SumByColor = cSum
End Function
Of course it's also far better not to use colours as data.
Bookmarks