View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Jim May
 
Posts: n/a
Default Counting Cells with Conditional Formatting

Here's a UDF (Put in a Standard module)

and use it in cell A1, like =CountByColor(A8:H8,6) << where 6 (at
present) = Yellow = change to =CountByColor(A8:H8,3) to get the reds
HTH


Function CountByColor(InRange As Range, WhatColorIndex As Integer) As Long
'
Dim c As Range
CountByColor = 0
Application.Volatile True
For Each c In InRange.Cells
If c.Interior.ColorIndex = WhatColorIndex Then
TCount = TCount + 1
End If
Next c
CountByColor = TCount
End Function

"JasonC" wrote:

Is there a way to look at a row of data that is either highlighted yellow or
red and to count only the data that is highlighted yellow and give me that
number?

None of my data is numerical....just one letter data, i.e.: "S" or "U"

I just want to count how many of the cells are highlighted yellow in a
specific row, if that makes more sense.