LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
mp mp is offline
external usenet poster
 
Posts: 70
Default Count cells with content in different color background



"Paula Luxenberg" wrote in message
...
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



and if you need to handle a cell that 'looks' blank but has a space(s) in
it...
If Len(Trim(Cell.Value))0 then
....


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change background color based on cell content from link joemc911 Excel Discussion (Misc queries) 0 April 22nd 10 04:52 PM
Change cell background color based on content that results from li joemc911 Excel Discussion (Misc queries) 4 March 24th 10 02:16 PM
Count cells in range w/specific background color? Michael[_3_] Excel Worksheet Functions 3 November 8th 08 05:51 AM
how to count cells with specific format (background color)? Blackheartedowl Excel Discussion (Misc queries) 1 February 8th 06 08:21 AM
How do you count cells with background color yellow? Stephanie D Excel Discussion (Misc queries) 6 October 18th 05 04:34 AM


All times are GMT +1. The time now is 07:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"