Function SumByHexColor(CellRange As Range, hexColor As String) As Double
Dim cell As Range
Dim totalSum As Double
Dim colorValue As Long
Application.Volatile
If Left(hexColor, 1) = "#" Then hexColor = Mid(hexColor, 2)
colorValue = CLng("&H" & Right(hexColor, 6))
For Each cell In CellRange
If cell.Interior.Color = colorValue Then
If IsNumeric(cell.Value) Then
totalSum = totalSum + cell.Value
End If
End If
Next cell
SumByHexColor = totalSum
End Function