Jo, try this UDF. It has two arguments, the first one, is the range you want to count (Similar to the range in COUNT or in SUM), and the second one, optional, is to count ONLY those cells that match the color of that selected cell.
Please not that if you change the shading of a cell the function WILL NOT recalculate, because changing formats doesn't generate any events nor will force a recalculation, so you'll have to edit the formula and press enter to get the result.
Function CountShades(Rng As Range, Optional RngColor As Range) As Double
Dim Color As Long
Dim Cll As Range
CountShades = 0
For Each Cll In Rng
If RngColor Is Nothing Then
If Cll.Interior.ColorIndex <> -4142 Then CountShades = CountShades + 1
Else
If Cll.Interior.Color = RngColor.Range("A1").Interior.Color Then CountShades = CountShades + 1
End If
Next Cll
End Function
Juan Pablo G.