View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
 
Posts: n/a
Default count colored cells?

Sorry about the response time...I did not see your message. The
ColorCount is a Function. Open the Visual Basic Editor
(Tools-Macro-Visual Basic Editor --or-- ALT-F11). Choose Insert-Module
(not class module). Copy and paste the code in the last post and then
you can use the function in your spreadsheet using the following
syntax:
=CountColor(ColorName,Range)

=CountColor("Dark Red",A1:B5)

will count the Dark Red backgrounds in the range A1 to B5.

One Caution:
The line:
If mycell.Interior.ColorIndex = myColorIndex Then CountColor =
CountColor + 1

is all one line. It might not paste that way.