Counting cells with colored font

  • Thread starter Thread starter JockW
  • Start date Start date
J

JockW

Hi,I know this can be done with Excel 2003 onwards, but I've got 2002 and I
can't find a way to count the cells in a range which have blue font and which
ones have red font.
Any ideas?
Range is C5:E17
 
This worked for me, just select a fixed cell and color code it so it knows
what color to refer to in the function. Add this macro to your visual basic..

Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As
Boolean)
Dim rCell As Range
Dim lCol As Long
Dim vResult

''''''''''''''''''''''''''''''''''''''
'Written by Ozgrid Business Applications
'www.ozgrid.com

'Sums or counts cells based on a specified fill color.
'''''''''''''''''''''''''''''''''''''''

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

ColorFunction = vResult
End Function
 
Hi Loretta, thanks for the reply. i'm not sure what you mean though!
How would the code know which cell to refer to, where would the result be
displayed.? Sorry to be a pain
Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top