count colored cells?

S

soxcpa

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top