#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 88
Default count color cell

Hi All,

can we count cells color?
for example in colom A.
in Row 1 = Blue
in Row 2 = Yellow
in Row 3 = Red
in Row 10 = Blue
in Row 53 = Blue

can you give a formula to count Blue....

thanks

reza
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default count color cell

There is no built-in excel function to do this. But you can use a UDF that
looks at the range and returns the sum of color. But that function will not
recalculate if you change color. Every time you change the color you will
need to recalculate or wait excel to recalculate...

To install the UDF (User Defined function). From workbook launch VBE using
Alt+F11. From menu Insert a Module and paste the below function.Close and get
back to workbook and try the below formula.

Function ColorSum(varRange As Range, varColor As Variant)
Dim arrTemp As Variant
Dim varTemp As Variant
For Each cell In varRange
varTemp = cell.Interior.ColorIndex
If varTemp = -4142 Then varTemp = 0
If varTemp = varColor Then ColorSum = ColorSum + 1
Next
End Function

To use the as a formula in range A1:A10 try the below; which will count the
number of blue cells....The second argument denotes the colorindex... Below
denotes the other colors...

=colorsum(A1:A10,5)

0 - No Color
1 - Black
2 - White
3 - Red
4 - Green
5 - Blue
6 - Yellow
7 - Magenta
8 - Cyan

If this post helps click Yes
---------------
Jacob Skaria


"reza" wrote:

Hi All,

can we count cells color?
for example in colom A.
in Row 1 = Blue
in Row 2 = Yellow
in Row 3 = Red
in Row 10 = Blue
in Row 53 = Blue

can you give a formula to count Blue....

thanks

reza

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 88
Default count color cell

greaatt.......

thanks boss

"Jacob Skaria" wrote:

There is no built-in excel function to do this. But you can use a UDF that
looks at the range and returns the sum of color. But that function will not
recalculate if you change color. Every time you change the color you will
need to recalculate or wait excel to recalculate...

To install the UDF (User Defined function). From workbook launch VBE using
Alt+F11. From menu Insert a Module and paste the below function.Close and get
back to workbook and try the below formula.

Function ColorSum(varRange As Range, varColor As Variant)
Dim arrTemp As Variant
Dim varTemp As Variant
For Each cell In varRange
varTemp = cell.Interior.ColorIndex
If varTemp = -4142 Then varTemp = 0
If varTemp = varColor Then ColorSum = ColorSum + 1
Next
End Function

To use the as a formula in range A1:A10 try the below; which will count the
number of blue cells....The second argument denotes the colorindex... Below
denotes the other colors...

=colorsum(A1:A10,5)

0 - No Color
1 - Black
2 - White
3 - Red
4 - Green
5 - Blue
6 - Yellow
7 - Magenta
8 - Cyan

If this post helps click Yes
---------------
Jacob Skaria


"reza" wrote:

Hi All,

can we count cells color?
for example in colom A.
in Row 1 = Blue
in Row 2 = Yellow
in Row 3 = Red
in Row 10 = Blue
in Row 53 = Blue

can you give a formula to count Blue....

thanks

reza

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
Count if a cell has color shading robnsd Excel Discussion (Misc queries) 3 April 23rd 23 03:46 AM
Excel 2007 formula to count color changes in a cell astrossmart Excel Worksheet Functions 1 December 2nd 08 04:54 PM
using vba to do a count for color cell tikchye_oldLearner57 Excel Discussion (Misc queries) 2 April 12th 07 02:32 AM
can i use the color of a cell to count the different colerd cells scott Excel Discussion (Misc queries) 1 June 17th 06 01:49 AM
detect cell color and count it Maileen Excel Worksheet Functions 2 March 31st 05 11:51 PM


All times are GMT +1. The time now is 03:15 AM.

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

About Us

"It's about Microsoft Excel"