You need a macro to do this.
try this UDF :
Copy and paste the below code to your module in VBE
in cell B8, place this formula =CountColor($A$8,$A$8:$A$400)
assuming that A8 is green, this will count all the green format cells
repeat this for red by changing the lookup value in the formula
Pls note that this will not work if you any of your color format in these
cells used conditional formatting.
Function CountColor(rColor As Range, rRange As Range, Optional SUM As Boolean)
Dim rCell As Range
Dim lCol As Long
Dim vResult
lCol = rColor.Interior.ColorIndex
If SUM = True Then
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = WorksheetFunction.SUM(rCell) + vResult
End If
Next rCell
Else
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = 1 + vResult
End If
Next rCell
End If
CountColor = vResult
End Function
Does this do what you want?
HTH
--
If this posting was helpful, please click on the Yes button
Thank You
cheers,