View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Paula Luxenberg Paula Luxenberg is offline
external usenet poster
 
Posts: 1
Default Count cells with content in different color background

I don't know how many colors you have and if they need to be dynamic,
but here's a simple macro:

Sub FindColorCells()
Dim ColorRange As String, Cell As Variant, ColorNumber As Long,
BlankCells As Integer, NonBlankCells As Integer

ColorRange = "A1:A10" 'Your Range
ColorNumber = 65535 'Your color (This is yellow)

For Each Cell In Range(ColorRange)
If Cell.Interior.Color = ColorNumber Then
If Cell.Value = vbNullString Then
BlankCells = BlankCells + 1
Else
NonBlankCells = NonBlankCells + 1
End If

End If
Next Cell

'The results of your macro
MsgBox "There were " & BlankCells & " blank cells and " &
NonBlankCells & " non blank cells in your range"

End Sub