Hi all members, I am working on a macro where i encountered an error
Code:
Function newreplace(rng2) As Range
Dim e(), f()
e = Array("( ){2,}", "^s", Chr(160), "^t{2,}", "(\([a-z]\)){1,4}")
f = Array("\1", " ", " ", "^t", "\1")
Dim i As Integer
For i = LBound(e) To UBound(e)
With rng2.find
.ClearFormatting
.Replacement.ClearFormatting
.Text = e(i)
.Replacement.Text = f(i)
.MatchWildcards = True
.Wrap = wdFindStop
End With
rng2.find.Execute Replace:=wdReplaceAll
Next
End Function
Here everything seems to work fine but when I reached the "with rng2.find" line VBA throws an error "424". I couldn't get a hint What did I miss? It would be a great help if someone points out what am I doing wrong and suggests a solution.