Count colored entries

G

Gary''s Student

I have a Word document that consists solely of a small table (3 across by 5
down).

How can I count how many table entries have a yellow background?
 
G

Greg Maxey

Sub ScratchMaco()
Dim oCell As Cell
Dim oCnt As Long
For Each oCell In ActiveDocument.Tables(1).Range.Cells
If oCell.Shading.BackgroundPatternColor = wdColorYellow Then
oCnt = oCnt + 1
end If
Next oCell
MsgBox oCnt
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

Top