View Single Post
 
Old 04-25-2022, 07:35 AM
Peterson Peterson is offline Windows 10 Office 2019
Competent Performer
 
Join Date: Jan 2017
Posts: 143
Peterson is on a distinguished road
Default

Try the code below. By the way, you are searching for spaces twice.

Code:
Sub nnewreplace()
    
    Dim e(), f()
    e = Array(" ", " ", Chr(160), Chr(9), "\(([a-z]{1,})\)")
    f = Array("", "", "", "", "\1.")
    Dim i As Integer
    Dim rng As Range
    Set rng = Selection.Range
    
    For i = LBound(e) To UBound(e)
        With rng.Find
            .ClearFormatting
            .MatchWildcards = True
            .Text = e(i)
            .Replacement.Text = f(i)
            .Wrap = wdFindStop
            .Execute Replace:=wdReplaceAll
        End With
    Next
End Sub
Reply With Quote