Function СуммаПоЦвету(Диапазон As Range, Цвет As Range) As Double
Dim Ячейка As Range
Dim Сумма As Double
For Each Ячейка In Диапазон
If Ячейка.Interior.Color = Цвет.Interior.Color Then
If IsNumeric(Ячейка.Value) Then
Сумма = Сумма + Ячейка.Value
End If
End If
Next Ячейка
СуммаПоЦвету = Сумма
End Function