Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
amvena
 
Posts: n/a
Default Counting coloured cells

I have a list of percentages that are conditionally formatted and I want to
be able to count how many cells are each different colour. I don't think you
can do this with count if as it only looks for numbers or text and not
formatting but essentially I want to count the number of cells in a range
which are red/gold or green.
  #2   Report Post  
Mangesh Yadav
 
Posts: n/a
Default

Use the following UDF


Function CountColor(rng As Range, colorRng As Range)

For Each cl In rng
If cl.Interior.ColorIndex = colorRng.Interior.ColorIndex Then ' use
this for background color
CountColor = CountColor + 1
End If
Next

End Function


Usage
=countcolor(A1:A10,A1)

A1:A10 is the range for which you want to count, and A1 is the cell which
has the desired color format which you want as criteria


Mangesh



"amvena" wrote in message
...
I have a list of percentages that are conditionally formatted and I want

to
be able to count how many cells are each different colour. I don't think

you
can do this with count if as it only looks for numbers or text and not
formatting but essentially I want to count the number of cells in a range
which are red/gold or green.



  #3   Report Post  
Bob Phillips
 
Posts: n/a
Default

This won't work for conditionally formatted cells. For that you need to test
whether it meets the CF condition.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mangesh Yadav" wrote in message
...
Use the following UDF


Function CountColor(rng As Range, colorRng As Range)

For Each cl In rng
If cl.Interior.ColorIndex = colorRng.Interior.ColorIndex Then '

use
this for background color
CountColor = CountColor + 1
End If
Next

End Function


Usage
=countcolor(A1:A10,A1)

A1:A10 is the range for which you want to count, and A1 is the cell which
has the desired color format which you want as criteria


Mangesh



"amvena" wrote in message
...
I have a list of percentages that are conditionally formatted and I want

to
be able to count how many cells are each different colour. I don't

think
you
can do this with count if as it only looks for numbers or text and not
formatting but essentially I want to count the number of cells in a

range
which are red/gold or green.





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 cells with a specific background colour Duncan Excel Discussion (Misc queries) 2 June 16th 05 11:04 PM
Counting unique text/number cells from a range sudeepd12 Excel Discussion (Misc queries) 3 June 15th 05 07:58 PM
Counting unique text/number cells from a range sudeepd12 Excel Worksheet Functions 2 June 14th 05 11:21 PM
complex fomula: counting cells that are blank shmurphing Excel Worksheet Functions 2 January 6th 05 09:55 PM
Counting blank cells in Pivot Table Andy Joyce Excel Worksheet Functions 1 December 21st 04 10:05 PM


All times are GMT +1. The time now is 05:51 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"