Count Red Cells

Function CountRed(myRange As Range) As Long
 Dim c As Range
 For Each c In myRange.Cells
  If c.Interior.ColorIndex = 3 Then CountRed = CountRed + 1
 Next c
End Function

Here is a more useful version that can be used with various colors (Use the color index for InteriorColor)

Function CountColor(myRange As Range, InteriorColor As Byte) As Long
 Dim c As Range
 For Each c In myRange.Cells
  If c.Interior.ColorIndex = InteriorColor Then CountColor = CountColor + 1
 Next c
End Function



© Copyright andrewsexceltips.net All Rights Reserved.