Function CountColor(rColor As Range, rSumRange As Range)
''''''''''''''''''''''''''''''''''''''
' Written by Ozgrid Business Applications
' www.ozgrid.com
' http://www.ozgrid.com/VBA/Sum.htm
' Counts cells based on a specified fill color.
'''''''''''''''''''''''''''''''''''''''
Dim rCell As Range
Dim iCol As Integer
Dim vResult
iCol = rColor.Interior.ColorIndex
For Each rCell In rSumRange
If rCell.Interior.ColorIndex = iCol Then
vResult = vResult + 1
End If
Next rCell
CountColor = vResult
End Function