currency with auto decimal and comma separator in a table

C

CMD@WTMA

How do I get a cell to automatically convert a number to currency with a
decimal point and comma separators? I do not need a formula in the cell I
would just like to type a number, say 5000, and have it automatically convert
to 5,000.00.
 
S

Suzanne S. Barnhill

This is not possible in Word (without a formula field) unless you embed an
Excel sheet.
 
G

Greg Maxey

As Suzanne says, it isn't possible (without a field). You could type the
number and then fire the following macro with an keyboard shortcut:

Sub ConvertSelectedRawNumbersInTableToCurrencyFormat()

If Not Selection.Information(wdWithInTable) Then
MsgBox "Place cursor in a table cell or select multiple cells."
Exit Sub
End If

Dim oCl As Word.Cell
Dim oRng As Range
Dim Count As Integer
For Each oCl In Selection.Cells
Set oRng = oCl.Range
oRng.End = oRng.End - 1
With oRng
If IsNumeric(oRng) Then
.Text = FormatCurrency _
(Expression:=.Text, _
NumDigitsAfterDecimal:=2, _
IncludeLeadingDigit:=vbTrue, _
UseParensForNegativeNumbers:=vbTrue)
End If
If IsNumeric(oRng) = False Then
Count = Count + 1
End If
End With
Next oCl
Selection.Collapse wdCollapseEnd
If Count = 1 Then
MsgBox "The selected cell is empty or content is not numerical.", ,
"Notice!!"
End If
If Count > 1 Then
MsgBox "" & Count & " of the selected cells are empty or content is not
numerical. Conversion complete on all selected numerical cells.", ,
"Notice!!"
End If
End Sub
 
J

Jim

Suzanne:

Can you give me some guidance on where I can learn about formula fields. I
have been through the entries in the Help menu and I do not understand. I
think I know what they're trying to say, but with few examples it is really
hard to put into application.

Thanks for any help you can give.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top