View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Luke M Luke M is offline
external usenet poster
 
Posts: 2,722
Default CountIF by Background Color

You can use this short UDF called CountYellow. Note that it only counts true
background color, not format generated by conditional formatting. Detecting
conditional formatting is quite a bit more complicated...

Public Function CountYellow(r As Range) As Double
Application.Volatile = True

CountColor = 0
For Each c In r
If c.Interior.ColorIndex = 6 Then
CountColor = CountColor + 1
End If
Next

End Function
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Phil H" wrote:

Need a formula to count the cells in a range with a background color yellow
(6).