Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-27-2023, 05:56 AM
gmayor's Avatar
gmayor gmayor is offline Find-and-Replace Special Characters Windows 10 Find-and-Replace Special Characters Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default


The following should work
Code:
Sub Macro1()
Dim vFindText As Variant
Dim vReplaceText As Variant
Dim oRng As Range
Dim i As Long
    vFindText = Array("%", "/")
    vReplaceText = Array(" PERCENT", " ")
    For i = 0 To UBound(vFindText)
        Set oRng = ActiveDocument.Range
        With oRng.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            Do While .Execute(findText:=vFindText(i), _
                              MatchWholeWord:=True, _
                              Forward:=True, _
                              Wrap:=wdFindStop) = True
                oRng.Text = vReplaceText(i)
                oRng.Collapse wdCollapseEnd
            Loop
        End With
    Next
lbl_Exit:
    Set oRng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find-and-Replace Special Characters Find/Replace text longer than 255 characters alex100 Word VBA 5 07-08-2020 04:14 AM
Find-and-Replace Special Characters Combining Characters in Find & Replace Surge Word 6 03-10-2020 12:42 AM
Find-and-Replace Special Characters multiple find and replace in vba for special words kvnrao Word VBA 7 11-02-2018 06:28 PM
Find-and-Replace Special Characters Search and Replace special characters between word using wildcards mauuuuu5 Word 1 08-23-2015 09:20 PM
Find-and-Replace Special Characters Find and Replace some characters with Bullets kjxavier Word 1 01-02-2015 12:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:37 AM.


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