Please help?

I am using the autofilter that is issuing the correct results. Some of the filtered cells have a colored background.

I have used the below function to sum cells defined by the cell color - but wish to now sum all of the filtered cells that contain the background color.

Dim rCell As Range
Dim 1Col As Long
Dim vResult

1Col = rColor.Interior.ColorIndex

If SUM = True Then
For Each rCell In rRange
If rCell.Interior.ColorIndex = 1Col Then
vResult = WorksheetFunction.SUM(rCell, vResult)
End If
Next rCell
Else
For Each rCell In rRange
If rCell.Interior.ColorIndex = 1Col Then
vResult = 1 + vResult
End If
Next rCell
End If

ColorFunction = vResult
---
I am not sure of the best way to go forward. Any guidance is appreciated.