Function SumByColor(CellColor As Range, SumRange As Range) Dim myCell As Range Dim iCol As Integer Dim myTotal
iCol = CellColor.Interior.ColorIndex
For Each myCell In SumRange If myCell.Interior.ColorIndex = iCol Then
myTotal = WorksheetFunction.Sum(myCell) + myTotal End If
Next myCell
SumByColor = myTotal End Function