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
 
Top