jo15765
07-01-2014, 12:29 PM
I recorde a macro and this is the syntax it gave me...I know often the macro recorder will give you overly cumbersome code. Is there a way to condense/shorten this or is this truly what is needed? This is what the macro recorder gave me -- also I am going to be running it in conjunction with this code http://www.vbaexpress.com/kb/getarticle.php?kb_id=13 Thank you @Steiner but will be searching for 4 different variations. I.E. the example shows ID but it could be eID, or empID or employeeID. Thanks in advance!
With Selection.Find
.Text = "ID"
.Replacement.Text = "Employee ID"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "ID"
.Replacement.Text = "Employee ID"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll