View Single Post
 
Old 09-30-2015, 05:08 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

It is probably quicker to look for the character than to step through each cell, then determine if it is in a table and if the cell it is in has the required shading.

Code:
Sub ReplaceInTable()
Dim orng As Range
    Set orng = ActiveDocument.Range
    With orng.Find
        Do While .Execute(FindText:="%")
            If orng.Information(wdWithInTable) Then
                If orng.Cells(1).Shading.BackgroundPatternColor = RGB(63, 123, 196) Then
                    orng.Text = " CB"
                    orng.Collapse 0
                End If
            End If
        Loop
    End With
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote