View Single Post
 
Old 11-19-2021, 01:31 AM
Bikram Bikram is offline Windows 10 Office 2007
Advanced Beginner
 
Join Date: Jul 2021
Location: Nepal
Posts: 90
Bikram is on a distinguished road
Default multiple replacing

I have 2 sub procedures to find multiple items and replace them in multiple files at once through vba my first procedure works fine but the second procedure is not working and I don't know why, can someone point out why the following code is not working? Thanks in advance.
It is the second procedure which is not working

Sub findM()
Dim strfind()
Dim strreplace()
Dim i As Integer

With Selection.Range
.find.ClearFormatting
.find.Replacement.ClearFormatting
End With
strfind = Array("cË", "km")
strreplace = Array("cª\u", "º")
For i = 0 To UBound(strfind)
With Selection.Range.find
.Text = strfind(i)
.Format = True
.Forward = True
.MatchAlefHamza = False
.MatchWildcards = False
.MatchWholeWord = False
.Replacement.Text = strreplace(i)
End With
Selection.find.Execute Replace:=wdReplaceAll
Next

End Sub
Reply With Quote