Highlighting

  • Thread starter Thread starter Lisa
  • Start date Start date
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??
 
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
 
Back
Top