#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 41
Default Counting Cell Color?

Is it possible to count the number of cells in a column by color? For
example if there are ten cells in a specific column that are colored red, can
I insert a formula to get that sum?


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 698
Default Counting Cell Color?


Chip can tell you about everything you will need to know on this subject.

http://www.cpearson.com/excel/colors.aspx


Or you can probably edit this down to only count the red cells. You will
need to name ther range to be counted Data.

Sub ColorCount()
'Counts the number of colored
'cells in a range named Data.
Dim Blue5 As Integer
Dim Red3 As Integer
Dim Green4 As Integer
Dim Yellow6 As Integer
Dim Cell As Range

For Each Cell In Range("Data") '("B1:F11")
If Cell.Interior.ColorIndex = 5 Then
Blue5 = Blue5 + 1
ElseIf Cell.Interior.ColorIndex = 3 Then
Red3 = Red3 + 1
ElseIf Cell.Interior.ColorIndex = 4 Then
Green4 = Green4 + 1
ElseIf Cell.Interior.ColorIndex = 6 Then
Yellow6 = Yellow6 + 1
End If
Next

Range("A1").Value = Blue5 & " Blue"
Range("A2").Value = Red3 & " Red"
Range("A3").Value = Green4 & " Green"
Range("A4").Value = Yellow6 & " Yellow"

MsgBox " You have: " & vbCr _
& vbCr & " Blue " & Blue5 _
& vbCr & " Red " & Red3 _
& vbCr & " Green " & Green4 _
& vbCr & " Yellow " & Yellow6, _
vbOKOnly, "CountColor"
End Sub

HTH
Regards,
Howard

"dwake" wrote in message
...
Is it possible to count the number of cells in a column by color? For
example if there are ten cells in a specific column that are colored red,
can
I insert a formula to get that sum?




  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 698
Default Counting Cell Color?

Forgot to say, my code does not work if the cells are colored by conditional
formatting.

Regards,
Howard

"dwake" wrote in message
...
Is it possible to count the number of cells in a column by color? For
example if there are ten cells in a specific column that are colored red,
can
I insert a formula to get that sum?




Reply
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
Counting by color Danny Boy Excel Worksheet Functions 3 April 22nd 10 09:28 PM
counting by color cc Excel Discussion (Misc queries) 8 July 23rd 08 11:41 AM
counting cell by color and condition Mark Excel Discussion (Misc queries) 1 April 22nd 07 04:56 PM
Excel: Syntax to change cell color based on color of another cell davew18 Excel Worksheet Functions 1 January 4th 07 01:24 PM
counting cell color help darkbearpooh1 Excel Worksheet Functions 4 January 25th 06 02:59 AM


All times are GMT +1. The time now is 01:37 AM.

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"