
01-03-2025, 06:24 AM
|
Novice
|
|
Join Date: Dec 2020
Location: TX, USA
Posts: 8
|
|
Quote:
Originally Posted by vivka
Hi! Try this code:
Code:
Sub FindReplaceAll()
Dim RngTxt as range, StrFind As String, StrRepl As String
Dim i As Long
StrFind = "<,>,#"
StrRepl = "-,-,-"
Selection.Collapse Direction:=wdCollapseStart
Set RngTxt = Selection.range
Selection.PasteSpecial DataType:=wdPasteText
RngTxt.End = Selection.range.End
RngTxt.Select
For i = 0 To UBound(Split(StrFind, ","))
Selection.Find.ClearFormatting
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.text = Split(StrFind, ",")(i)
.Replacement.text = Split(StrRepl, ",")(i)
.Format = False
.MatchWholeWord = True
.MatchAllWordForms = False
.MatchWildcards = False
.Execute Replace:=wdReplaceAll
End With
Next i
Selection.Copy
End Sub
|
Thank you, Vivka. Your solution worked perfectly!
|