Results 1 to 11 of 11
  1. #1
    New Lounger
    Join Date
    Oct 2018
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Number Formatting - MS Word

    Hi,

    I want to convert the figure's format in Word document from "General" to " Accounting". For ex. 100000 to 100,000.
    Please let me know, is there any easy way to do that ?

    Regards,
    Eklaveya Dubey

  2. #2
    Silver Lounger kweaver's Avatar
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,690
    Thanks
    59
    Thanked 88 Times in 82 Posts
    Word, unfortunately, doesn't offer a simple way to format numbers like Excel.

    You could link an Excel sheet to your Word document to more easily accomplish this.

    Alternatively (but not particularly easy) is to insert a table in the Word document. In a simplistic case, you might put numbers in the first row.
    Then, position the mouse and insertion point in the second row, 1st cell, and from the keyboard enter: CTRL+F9 which will create field braces.
    Inside the braces enter: =A1 \# "#,###" which says to Word to use the first row, first column (like Excel) and format it with a comma in thousands.
    Copy that formula to the "B column" etc. but change the cell pointer to B1, C1, etc. Now enter values in the first row, select the table, and update the table using the F9 key. [pain] Then, ALT+F9 will close all the fields just entered.

    I've done this when I really was forced to stay within Word. You could remove the borders and change the font color in the first row to white (to match the page).

    I'd really suggest using a link to Excel, however.
    Last edited by kweaver; 2018-10-11 at 13:33.

  3. #3
    WS Lounge VIP Lugh's Avatar
    Join Date
    Jun 2010
    Location
    Indy
    Posts
    1,272
    Thanks
    291
    Thanked 197 Times in 170 Posts
    Hi Eklaveya, welcome to WS Lounge ☺

    What version of Word are you using?

    What are you trying to achieve that simply typing…
    100,000
    …won't accomplish?
    Lugh.
    ~
    Dell Alienware Aurora R6; Win10 Home x64 1803; Office 365 x32
    i7-7700; GeForce GTX 1060; 16GB DDR4 2400; 2 x 256G SSD, 4TB HD

  4. #4
    New Lounger
    Join Date
    Oct 2018
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, Kweaver.
    But I am having large volume of data to be converted. So I think i have to apply some VBA codes for that which I am trying to get.
    But thanks for your valuable inputs.

  5. #5
    New Lounger
    Join Date
    Oct 2018
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Lugh, but I am having large volume of data, which I think could be possible by VBA codes & I am trying to get that..

  6. #6
    New Lounger
    Join Date
    Oct 2018
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Or someone is aware, how to use FIND & REPLACE option by turning on "Use wildcards"..?

  7. #7
    WS Lounge VIP Lugh's Avatar
    Join Date
    Jun 2010
    Location
    Indy
    Posts
    1,272
    Thanks
    291
    Thanked 197 Times in 170 Posts
    Quote Originally Posted by EKLAVEYA View Post
    Or someone is aware, how to use FIND & REPLACE option by turning on "Use wildcards"..?
    There is a Find/Replace code…
    ^#
    …which means 'any digit', but I don't see how you could use it easily—problem is, there isn't an 'any non-digit' code which you need to use with ^#.

    My guess is you'll need to use a regular expression, specifically the square bracket option [ ]

    Check out Graham Mayor's page on it, Graham is one of the regular Word expert posters here.
    Lugh.
    ~
    Dell Alienware Aurora R6; Win10 Home x64 1803; Office 365 x32
    i7-7700; GeForce GTX 1060; 16GB DDR4 2400; 2 x 256G SSD, 4TB HD

  8. #8
    New Lounger
    Join Date
    Oct 2018
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Lugh.
    I got the VBA Codes for converting the digits from general format to accounting format but I have to select the digits column page by page individually. Is there any option to change these codes to run for the whole document ? Codes are:

    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

  9. #9
    2 Star Lounger Graham Mayor's Avatar
    Join Date
    Mar 2016
    Location
    Cyprus
    Posts
    111
    Thanks
    0
    Thanked 40 Times in 38 Posts
    How about

    Code:
    Sub FormatNumbers()
    Dim orng As Range
        Set orng = ActiveDocument.Range
        With orng.Find
            Do While .Execute(FindText:="[0-9]{4,}", MatchWildcards:=True)
                orng.Text = Format(orng.Text, "###,###,##0")
                orng.Collapse 0
            Loop
        End With
    lbl_Exit:
        Set orng = Nothing
        Exit Sub
    End Sub
    Graham Mayor - Word MVP
    http://www.gmayor.com

  10. #10
    New Lounger
    Join Date
    Oct 2018
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    THANKS Graham, u are really awesome.
    It's of great help.

  11. #11
    New Lounger
    Join Date
    Oct 2018
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks to other's also, as they have taken initiative to sort out my problem.
    Thanks Guys.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •