cell number format
Dim i As Long, mynum As Range
With ActiveDocument.Tables(1)
For i = 2 To .Rows.Count
Set mynum = .Cell(i, 3).Range
mynum.End = mynum.End - 1
.Cell(i, 3).Range = format(mynum, "#,##0")
Set mynum = .Cell(i, 7).Range
mynum.End = mynum.End - 1
.Cell(i, 7).Range = format(mynum, "#,##0")
Next i
End With
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
"Helmut" wrote in message
...
I have one table in a word document. In column 3 and 7 starting from row 2
I
want to change the input 10000 to 10,000.
I found the following:
Sub format()
'
Dim i As Long, mynum As Range
With ActiveDocument.Tables(1)
For i = 2 To .Rows.Count
Set mynum = .Cell(i, 3).Range
mynum.End = mynum.End - 1
.Cell(i, 3).Range = format(mynum, "#,##0")
Next i
End With
End Sub
--------------------------
It works fine for column 3, but when I change the 3 to 7 in a second sub,
it
changes the values, but stops at:
Set mynum = .Cell(i, 7).Range
===========
Is there anyway I can do both columns in one macro?
what's the code?
thanks
|