Hi there
Chip Pearson's method is the best - and the one I would have pointed you towards had you not already found it.
However, if it's just a simple count by colour you need, then you could try this previous version of Chip's function. It doesn't include any other functions - just the simple count. And you don't need to download the module. I've used this in the past and it works just fine.
From Excel, press Alt+F11 to open the VBE. Add a new module and copy and paste the following into the module
Function CountByColor(InRange As Range, _
WhatColorIndex As Integer, _
Optional OfText As Boolean = False) As Long
'
' This function return the number of cells in InRange with
' a background color, or if OfText is True a font color,
' equal to WhatColorIndex.
'
Dim rng As Range
Application.Volatile True
For Each rng In InRange.Cells
If OfText = True Then
CountByColor = CountByColor - _
(rng.Font.ColorIndex = WhatColorIndex)
Else
CountByColor = CountByColor - _
(rng.Interior.ColorIndex = WhatColorIndex)
End If
Next rng
End Function
This is the function that does the counting.
Of course, you need to know the index number of each colour. To find the number, copy this code and run it on another sheet
Sub ListColours()
Dim x As Integer
For x = 1 To 56
ActiveSheet.Cells(x, 1).Interior.ColorIndex = x
Next
End Sub
This will list all the colours available - just read off the colour number against the row number. For example, yellow = 6.
Now you can insert the formula in your total row
=CountByColor(C1:C5,6,FALSE) or use Insert Function to choose from the User Defined List.
The function should re-calculate automatically as it uses Application.Volatile - you'll probably need to click in another cell to ensure it actually does it.
Any problems just post back.