Highlighting

L

Lisa

I have a report with multiple columns and rows, this is
reviewed for errors and any that are found are highlighted
yellow. What I am wanting to do is be able to say "count
any cell highlighted in yellow and sum" Does anyone know
if this can be done or am I just dreaming??
 
F

Filip Mateasko

Hi Lisa,
try this:

Sub CountYellow()

Dim counter As Integer
Dim r As Range
counter = 0

Set r = Range("A1", Range("A1").SpecialCells(xlLastCell))
For Each c In r.cells
If c.Interior.ColorIndex = 6 Then counter = counter + 1
Next
MsgBox counter
End Sub


Maybe you will need to change the Colorindex, it depends on which yellow you
use.
You can also modify the MsgBox to show you some additional informations ;-)

Regards
Filip
 

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