ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Counting cell colours (https://www.excelbanter.com/excel-worksheet-functions/165804-counting-cell-colours.html)

jc132568

Counting cell colours
 
Dear experts,
In my worksheets I have a "traffic light" system where cells with particular
values turn assigned cells in another location red, green or yellow using
conditional formatting. This provides me with a quick reference. My
question is can I count cells according to their colouring. Then I could say
I've got 20 cases complete, 10 cases in process, and 2 cases pending for
example. I know I could count the cells at the site of the original data but
counting the "traffic lights" would add to my summary info.
Thanks
JC

ryguy7272

Counting cell colours
 
Take a look at this:
(Counting Cells With A Specific Color)
http://www.cpearson.com/excel/colors.htm


You could try this macro too:
Sub countcolor()
Dim rng As Range
Dim cnt As Long

Set rng = Range("A1:E12")
cnt = 0

For Each cell In rng
If cell.Interior.ColorIndex = 3 Then
cnt = cnt + 1
End If
Next
MsgBox cnt
Range("G1").Value = cnt
End Sub



Regards,
Ryan--

--
RyGuy


"jc132568" wrote:

Dear experts,
In my worksheets I have a "traffic light" system where cells with particular
values turn assigned cells in another location red, green or yellow using
conditional formatting. This provides me with a quick reference. My
question is can I count cells according to their colouring. Then I could say
I've got 20 cases complete, 10 cases in process, and 2 cases pending for
example. I know I could count the cells at the site of the original data but
counting the "traffic lights" would add to my summary info.
Thanks
JC


carlo

Counting cell colours
 
On Nov 13, 11:13 am, jc132568
wrote:
Dear experts,
In my worksheets I have a "traffic light" system where cells with particular
values turn assigned cells in another location red, green or yellow using
conditional formatting. This provides me with a quick reference. My
question is can I count cells according to their colouring. Then I could say
I've got 20 cases complete, 10 cases in process, and 2 cases pending for
example. I know I could count the cells at the site of the original data but
counting the "traffic lights" would add to my summary info.
Thanks
JC


If the TrafficLight cells have distinguished values in them, then it
shouldn't be a problem
Let's say Red = 1, Yellow = 2, Green = 3, you can use the countif
function.
If they are Empty, you could use the same formula you have in
conditional formatting
to populate those cells!

Hth

Carlo


jc132568

Counting cell colours
 
Thank you, makes sense. Much appreciated.

"carlo" wrote:

On Nov 13, 11:13 am, jc132568
wrote:
Dear experts,
In my worksheets I have a "traffic light" system where cells with particular
values turn assigned cells in another location red, green or yellow using
conditional formatting. This provides me with a quick reference. My
question is can I count cells according to their colouring. Then I could say
I've got 20 cases complete, 10 cases in process, and 2 cases pending for
example. I know I could count the cells at the site of the original data but
counting the "traffic lights" would add to my summary info.
Thanks
JC


If the TrafficLight cells have distinguished values in them, then it
shouldn't be a problem
Let's say Red = 1, Yellow = 2, Green = 3, you can use the countif
function.
If they are Empty, you could use the same formula you have in
conditional formatting
to populate those cells!

Hth

Carlo



Gord Dibben

Counting cell colours
 
ryguy

You posted the correct URL for Chip's site but did not read the site
introduction info before posting.

NOTE: These functions will not detect colors that are applied by Conditional
Formatting. They will read only the default colors of the cell and its text.
For information about returning colors in effect by conditional formatting, see
the Conditional Formatting Colors page.

See Chip's site and hit the link for more info and methods.

http://www.cpearson.com/excel/CFColors.htm


Gord Dibben MS Excel MVP


On Mon, 12 Nov 2007 18:25:00 -0800, ryguy7272
wrote:

Take a look at this:
(Counting Cells With A Specific Color)
http://www.cpearson.com/excel/colors.htm


You could try this macro too:
Sub countcolor()
Dim rng As Range
Dim cnt As Long

Set rng = Range("A1:E12")
cnt = 0

For Each cell In rng
If cell.Interior.ColorIndex = 3 Then
cnt = cnt + 1
End If
Next
MsgBox cnt
Range("G1").Value = cnt
End Sub



Regards,
Ryan--




All times are GMT +1. The time now is 03:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com