Counting Cells with a certain fill colo(u)r


Posted by Tony on August 10, 2001 7:47 AM

Is it possible to perform a 'countif' based on the criteria being a fill colo(u)r?

Thanks



Posted by cpod on August 10, 2001 1:29 PM

Here is a function that will sum a range by fill color:

Public Function SumbyColor(rngSum As Range, rngColor As Range) As Double
Dim lngColor As Long, C As Range
lngColor = rngColor.Interior.Color
For Each C In rngSum
If C.Interior.Color = lngColor Then
SumbyColor = SumbyColor + C
End If
Next
End Function

The first argument is the range to sum. The second arguement is the address of any cell with the required cell fill color.