View Single Post
 
Old 03-01-2020, 08:58 PM
Leslie Leslie is offline Windows 8 Office 2010
Novice
 
Join Date: Oct 2019
Posts: 13
Leslie is on a distinguished road
Default

Code:
Sub FnR(Rng As Range)
Dim strFindText As String, strReplaceText As String, nSplitItem  As Long
strFindText = "northenn,westenn"
strReplaceText = "northern,western"
With Rng.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Forward = True
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .Wrap = wdFindContinue
  For nSplitItem = 0 To UBound(Split(strFindText, ","))
    .Text = Split(strFindText, ",")(nSplitItem)
    .Replacement.Text = Split(strReplaceText, ",")(nSplitItem)
    .Execute Replace:=wdReplaceAll
  Next
End With
End Sub
Replaced 'Replace' with 'strReplaceText' in the above code (executes fine now).

Perfect code!

Thanks dear Paul Edstein @macropod.
Reply With Quote