Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Count Format Types

How do I count the number of cells in a worksheet that contain a certain
format, i.e. shaded yellow?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default Count Format Types

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,6)

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


"TByersTX" wrote:

How do I count the number of cells in a worksheet that contain a certain
format, i.e. shaded yellow?

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,276
Default Count Format Types

Hi,
see CPearson Web

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

"TByersTX" wrote:

How do I count the number of cells in a worksheet that contain a certain
format, i.e. shaded yellow?

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Count Format Types

Thanks Jacob,

The first time I followed your directions, it worked like a charm. When I
retrieve the new macro enabled worksheet, the formula gives me the "#NAME?"
error. I can retrieve the old worksheet and start over, and it works like a
charm again. Every time after saving, I get the same error. Any ideas?


"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,6)

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


"TByersTX" wrote:

How do I count the number of cells in a worksheet that contain a certain
format, i.e. shaded yellow?

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
Excel 2007 error "some chart types cannot be combined with other chart types. Select a different chart types" roadsidetree Charts and Charting in Excel 15 June 2nd 09 10:53 AM
Count No of Types. HARSHAWARDHAN. S .SHASTRI[_2_] Excel Worksheet Functions 5 February 5th 09 04:12 PM
Count cells by format GeneR Excel Worksheet Functions 2 December 28th 06 02:01 AM
How can I format the #of decimals, field types, etc. automaticall. JOET Excel Discussion (Misc queries) 1 April 2nd 05 12:14 AM
Count format changes Dr. Juzzy Excel Discussion (Misc queries) 2 January 30th 05 01:25 PM


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