Macro to delete text from cells with specific format
Hi
my first post here.
I am trying to create a macro that can delete the text out of all blue cells in my forms.
I used an existing macro and modified it but cant seem to get it work.
The command "myCell.ClearContents" doesn't want to work.
What am I doing wrong?
Sub DeleteTextFromBlueCells()
If Not Selection.Information(wdWithInTable) Then
MsgBox "Place the cursor in a table cell with a colored pattern."
Exit Sub
End If
Dim myRange As Range
CurrentTexture = Selection.Range.Cells(1).Shading.Texture
CurrentForegroundPatternColor = Selection.Range.Cells(1).Shading.ForegroundPattern Color
CurrentBackgroundPatternColor = Selection.Range.Cells(1).Shading.BackgroundPattern Color
For Each myTable In ActiveDocument.Tables
Set myRange = myTable.Range
For Each myCell In myRange.Cells
If myCell.Shading.Texture = CurrentTexture _
And myCell.Shading.ForegroundPatternColor = CurrentForegroundPatternColor _
And myCell.Shading.BackgroundPatternColor = CurrentBackgroundPatternColor Then
myCell.ClearContents
End If
Next myCell
Next myTable
End Sub
|