Counting shaded cells

  • Thread starter Thread starter demon42
  • Start date Start date
D

demon42

I have a very large excel table that my lab uses for test results. A
good portion of the table has been grayed out for various hardware
reasons. I would like to be able to count the number of shaded cells in
the table to get a completion percentage, and im not sure how (is there
a way? :confused: ) withouth manually counting them myself which would
be tremendously tedious.

I am running Excel 2000, but if it made a difference I could upgrade
without a problem if needed.

I have a feeling this might have to be a VB script...

Thank you in advance!
 
Let's assume that shaded means that the background color index = 48. First
select a pile of cells and then run:

Sub shady()
Dim r As Range
Dim IAmTheCount As Long
Dim j As Integer
IAmTheCount = 0
For Each r In Selection
j = r.Interior.ColorIndex
If j = 48 Then
IAmTheCount = IAmTheCount + 1
End If
Next
MsgBox IAmTheCount
End Sub
 

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

Back
Top