How to Count only Colored cells

W

WM_1956

I'm new to Excel, but I've been asked to create a worksheet that ha
colored cells showing when a project is completed. My problem is
need to do a "count" on the completed(colored cells). How can I d
this?

Thanks for any help...
Wm_195
 
J

jtp

Hi WM,
You need to be a little more specific. Are performing a differen
count on each color or just any color? Also are you going by just row
column or an entire worksheet? The procedure below will count an
colored cell in column A. I am also assuming that you have data i
these cells. If not, the For loop will have to be changed as it wil
not pick up the upper limit.

If you are completely new to Excel and do not know how/where to pu
your VBA code, take a look at this site... Found this from a thread b
Norman Jones

David McRitchie's 'Getting Started With Macros And
User Defined Functions' at:

http://www.mvps.org/dmcritchie/excel/getstarted.htm


You might also look at David's tutorials page at:

http://www.mvps.org/dmcritchie/excel....htm#tutorials

The VBA material is towards the end of that section.

-Sub CountColoredCells()
Dim cell As Range, i As Integer, totals As Integer

Set cell = Range("A1")

totals = 0
For i = 0 To Range("A1").End(xlDown).Row - 1
If cell.Offset(i, 0).Interior.ColorIndex <> xlNone Then
totals = totals + 1
End If
Next
cell.Offset(i, 0).Value = totals

End Sub-
Hope this helps some,

Jason


I'm new to Excel, but I've been asked to create a worksheet that ha
colored cells showing when a project is completed. My problem is I nee
to do a "count" on the completed(colored cells). How can I do this
 

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