View Single Post
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Replacing numbers automatically

No automatic method, short of pressing the comma key where required.
the following macro will format a selected number

Sub FormattedNumber()
Dim sNum As String
sNum = Selection
If sNum = "" Then Exit Sub
If sNum Int(sNum) Then
sNum = format(sNum, "###,###,###,###.##")
Else
sNum = format(sNum, "###,###,###,###")
End If
Selection.TypeText sNum
End Sub

but it is just as quick to manually insert the commas.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



L. Mohan Arun wrote:
Is there a way to get this done in Word:

I type 4126 it should produce 4,126.
I type 39922 it should produce 39,922.

In short I am looking to format the number automatically.

---------------
Read my blog
http://interestsblog.blogspot.com