Thread: [Solved] Round off the number
View Single Post
 
Old 09-04-2012, 09:59 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

In that case, you could use code like:
Code:
Sub FormatNumbers()
Dim Rng As Range, Tbl As Table, oCll As Cell, StrFmt As String
With Selection
  If .Information(wdWithInTable) = True Then
    For Each oCll In .Tables(1).Range.Cells
      Set Rng = oCll.Range
      Rng.End = Rng.End - 1
      If IsNumeric(Rng.Text) Then
        If Left(Rng.Text, 1) Like "[$€ге]" Then
          StrFmt = Left(Rng.Text, 1)
        Else
          StrFmt = ""
        End If
        If InStr(Rng.Text, ",") > 0 Then
          Rng.Text = StrFmt & Format(Round(Rng.Text, 0), "#,###")
        Else
          Rng.Text = StrFmt & Round(Rng.Text, 0)
        End If
      End If
    Next
  End If
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote