Forum Discussion
175429
Oct 17, 2025Copper Contributor
Multi-replace Macro
Hey all, I need some assistance creating a macro that replaces multiple phrases. Below are the phrases I have and the phrases I want them changed to without having to manually use "Find and R...
Kidd_Ip
Oct 18, 2025MVP
How about this:
Sub MultiReplace()
Dim replacements As Variant
Dim i As Integer
' Define your phrases and replacements
replacements = Array( _
Array("ROr ROY", "LK Fin"), _
Array("OKP and DON", "HU Dep"), _
Array("Signs (Single)", "PE Dep") _
)
' Loop through each pair and replace
For i = LBound(replacements) To UBound(replacements)
With ActiveDocument.Content.Find
.Text = replacements(i)(0)
.Replacement.Text = replacements(i)(1)
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With
Next i
End Sub