Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
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
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
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 |
#3
Posted to microsoft.public.word.formatting.longdocs
|
|||
|
|||
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 |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
number format in word to show the comma as a seperator | Microsoft Word Help | |||
adding thousand separators in ms word | New Users | |||
Easier way to change decimal and thousand separators | Microsoft Word Help | |||
How do I autoformat thousand seperator in Word tables? | Tables | |||
Want to use 100 seperator instead of 1000 seperator | Microsoft Word Help |