Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 04-25-2022, 07:35 AM
Peterson Peterson is offline replacing_within_range Windows 10 replacing_within_range 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
 



Other Forums: Access Forums

All times are GMT -7. The time now is 05:36 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft