Function sumByBGC(r As RANGE, c As String)
'sum by background color
Dim result As Long
result = 0
Debug.Print c
For Each cell In r
Debug.Print cell
With cell
If cell.Interior.ColorIndex = RANGE(c).Interior.ColorIndex Then
result = result + cell.Value
End If
End With
Next
sumByBGC = result
End Function
Open in new window
Kyle