Function sum_color(myRange As Range, myColor As Range, Optional myType = 0) As Double
Dim summ As Double
summ = 0
For Each c In myRange
If myType = 1 And c.Interior.Color = myColor.Interior.Color Then summ = summ + c.Text
If myType = 0 And c.Interior.Color = myColor.Interior.Color Then summ = summ + 1
Next
sum_color = summ
End Function