View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Shane Devenshire[_2_] Shane Devenshire[_2_] is offline
external usenet poster
 
Posts: 3,346
Default how do I use COUNTIF stmnt if I want to find cells that are red

Hi,

Here is a general custom function that counts the number of cells that have
a certain color.

Function CountFormats(R As Range, E As Range) As Integer
Dim cell As Range
Dim Total As Integer
Dim T As Boolean
Set S = E.Cells(1, 1)
Total = 0
For Each cell In R
T = True
With cell
If .Interior.ColorIndex < S.Interior.ColorIndex Then T = False
End With
If T = True Then
Total = Total + 1
End If
Next cell
CountFormats = Total
End Function

If this helps, please click the Yes button

Cheers,
Shane Devenshire

"kisboros" wrote:

Can COUNTIF work if I want to count cells that are highlighted, let's say, red?
Thank you.