A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Formatting Long Documents
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Thousand seperator for number



 
 
Thread Tools Display Modes
  #1  
Old January 15th, 2010, 12:47 PM posted to microsoft.public.word.formatting.longdocs
shbutt
external usenet poster
 
Posts: 3
Default Thousand seperator for number

I work with huge numbers in tables a lot and need to use thousand seperator
formatting on these numbers. What should I do to automatically apply desired
formatting on selected numbers. Is there any default setting in word for this
or any vba macro?

I am using Word 2007 on Win XP.

Regards,

Shahbaz
  #2  
Old January 15th, 2010, 01:32 PM posted to microsoft.public.word.formatting.longdocs
macropod[_2_]
external usenet poster
 
Posts: 2,402
Default Thousand seperator for number

Hi shbutt,

There's no auto-formatting for numbers in Word, but the following macro will format any selected table cells containing only
unformatted numbers:

Sub NumberFormat()
Dim oCel As Cell, RngCel As Range
With Selection
If .Information(wdWithInTable) = True Then
For Each oCel In .Cells
Set RngCel = oCel.Range
RngCel.MoveEnd Unit:=wdCharacter, Count:=-1
If IsNumeric(RngCel.Text) Then
If InStr(RngCel.Text, ",") = 0 Then
If InStr(RngCel.Text, ".") = 0 Then
RngCel.Text = Format(RngCel.Text, "#,##0")
Else
RngCel.Text = Format(RngCel.Text, "#,##0.00")
End If
End If
End If
Next
Set RngCel = Nothing
End If
End With
End Sub

As coded, numbers:
.. without decimal places will be given thousands separators; and
.. with decimal places will be given thousands separators and rounded to 2 decimal places.

--
Cheers
macropod
[Microsoft MVP - Word]


"shbutt" wrote in message ...
I work with huge numbers in tables a lot and need to use thousand seperator
formatting on these numbers. What should I do to automatically apply desired
formatting on selected numbers. Is there any default setting in word for this
or any vba macro?

I am using Word 2007 on Win XP.

Regards,

Shahbaz


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:23 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.