A family of Microsoft word processing software products for creating web, email, and print documents.
Change wdReplaceAll to wdReplaceOne; Word will format only the first matching dollar amount encountered. wdReplaceOne means “replace the first occurrence,” whereas wdReplaceAll processes every occurrence.^1^
Sub Dollar_Colour_Red_Bold2()
Options.DefaultHighlightColorIndex = wdYellow
With Selection.Find
.ClearFormatting
.Font.Size = 12
.Text = "($[0-9,]{1,})"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchWildcards = True
With .Replacement
.ClearFormatting
.Text = "\1"
.Font.Bold = True
.Font.Color = wdColorRed
.Highlight = True
End With
.Execute Replace:=wdReplaceOne
End With
End Sub
Each time the macro runs, it finds and formats one occurrence. Because .Forward = True, it searches forward from the current selection; .Wrap = wdFindContinue allows the search to continue from the beginning after reaching the document’s end.^2^
References