View Single Post
 
Old 10-16-2019, 05:03 AM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim lngCount
Dim oCell As Cell
Dim oRng As Range
  For Each oCell In Selection.Tables(1).Range.Cells
    If oCell.Range.Information(wdEndOfRangeColumnNumber) = 2 Then 'or whatever column index you need
      If oCell.Shading.BackgroundPatternColor = wdColorAutomatic Then
        Set oRng = oCell.Range
        oRng.End = oRng.End - 1
        lngCount = lngCount + oRng.ComputeStatistics(wdStatisticWords)
      End If
    End If
  Next
  MsgBox lngCount
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote