Very good! Now for a little refinement that will speed it up a bit:
In the first Find, change the .Text string to
.Text = "(-)([0-9]{1,}.[0-9]{1,})"
and change the .Replacement.Text string to
.Replacement.Text = "(\2)"
The added parentheses in the .Text string separate it into two
substrings, and the \2 in the .Replacement.Text string says to use
only the second substring -- that is, drop the minus sign. Then you
can eliminate the second Find.
This and more is at
http://www.mvps.org/word/FAQs/General/UsingWildcards.htm.
Jon said:
Worked it out;;;
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "-[0-9]{1,}.[0-9]{1,}"
.Replacement.Text = "(^&)"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "\(-"
.Replacement.Text = "("
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Find.Execute Replace:=wdReplaceAll
Jon said:
Hi
I have a selection of text mostly in a table, but some in free text,
that
I
would like to replace all negative numbers (eg -99.24) with () so it would
read (99.24).
Can anyone help me please? I'll searched google and found nothing that
helps me. Can it be done using the find/replace dialog? Or is it a VBA
macro?
I'd prefer macro!
Thanks very much for your help