View Single Post
 
Old 07-14-2021, 02:55 PM
NoLockdownsLOL NoLockdownsLOL is offline Windows 10 Office 2019
Novice
 
Join Date: Jul 2021
Location: Brisbane, Australia
Posts: 4
NoLockdownsLOL is on a distinguished road
Default replace specific text within brackets

Hi

I have no idea where to start with this one (can clear all text within parenthesis no problem but i specifically need to delete as follows)

I am looking to delete all text with the following criteria when in parenthesis

some start with

(formerly )

and some are

(formerly John Wilson)

with John Wilson being totally random could be any combination up to 25 characters

End result - all deleted including parenthesis


Any help greatly appreciated

Thanks Steve


The following works for (formerly ) as above but needing to catch (formerly John Wilson) << John Wilson could be anything random

Sub replacetext()
Dim test
test = "(formerly )"

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = test
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Last edited by NoLockdownsLOL; 07-14-2021 at 05:04 PM.
Reply With Quote