Function CountCcolor(range_data As Range, ColorIndex As Variant, Optional Equal As Boolean = True) As Long
Dim datax As Range
Dim xcolor As Long
If TypeName(ColorIndex) = "Range" _
Then xcolor = ColorIndex.Interior.ColorIndex _
Else xcolor = ColorIndex
For Each datax In range_data
If Equal Then
If datax.Interior.ColorIndex = xcolor Then CountCcolor = CountCcolor + 1
Else
If datax.Interior.ColorIndex <> xcolor Then CountCcolor = CountCcolor + 1
End If
Next datax
End Function