View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
FSt1 FSt1 is offline
external usenet poster
 
Posts: 3,942
Default Is there a way to count cells in a range with a given backcolor?

hi
Sub countcolor()
Dim rng As Range
Dim cnt As Long

Set rng = Range("A2:I30")
cnt = 0

For Each cell In rng
If cell.Interior.ColorIndex = 40 Then
cnt = cnt + 1
End If
Next
MsgBox cnt
'or Range("K2").Value = cnt

End Sub

see this site for color indexes...
http://www.mvps.org/dmcritchie/excel/colors.htm

regards
FSt1

"David" wrote:

Is there a function to count the cells in a range, which have a given
interior color?