Soldato
- Joined
- 10 May 2004
- Posts
- 13,047
- Location
- Sunny Stafford
I have written VBA macros that replaces one string with another (simple find/replace), and VBA that finds a string and formats it to a particular colour, such as this:
What I would like to find out is how to search for a string and delete the whole line/paragraph that contains that string. Then, repeat throughout the document until all of the containing lines are deleted. It would be ideal for the lines below to shunt up 1 so that no blank lines are left behind, to the effect of selecting a line using triple-left-click and pressing the backspace button.
Thanks!
Code:
Sub FormatWords()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Testing"
.Replacement.Text = ""
.Replacement.Font.ColorIndex = 5
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
What I would like to find out is how to search for a string and delete the whole line/paragraph that contains that string. Then, repeat throughout the document until all of the containing lines are deleted. It would be ideal for the lines below to shunt up 1 so that no blank lines are left behind, to the effect of selecting a line using triple-left-click and pressing the backspace button.
Thanks!