formatting numbers in a cell

J

juan

Hi, I have a table in a document that is filled with a userform, how can I
format numbers in a cell (2345.00 insted of 2345) and right align those
numbers ?

With ActiveDocument.Tables(1).Cell(Row:=Fila, Column:=5).Range
.Delete
.InsertAfter Text:=TextValor.Value * TextCantidad.Value
End With

Thanks
Juan Uribe
 
J

Jay Freedman

Don't try to format the numbers after they're in the cell; that's too
hard. Use the Format function to format the string before you put it
into the cell. Then use the Alignment property to align it. Also note
that you don't have to delete the current contents and then
InsertAfter; just assign the string to the .Text property of the range
and it will replace whatever is there.

With ActiveDocument.Tables(1).Cell(Row:=Fila, Column:=5).Range
.Text = Format(TextValor.Value * TextCantidad.Value, "#.00")
.ParagraphFormat.Alignment = wdAlignParagraphRight
End With
 
J

juan

Thanks Jay, very helpfull

Jay Freedman said:
Don't try to format the numbers after they're in the cell; that's too
hard. Use the Format function to format the string before you put it
into the cell. Then use the Alignment property to align it. Also note
that you don't have to delete the current contents and then
InsertAfter; just assign the string to the .Text property of the range
and it will replace whatever is there.

With ActiveDocument.Tables(1).Cell(Row:=Fila, Column:=5).Range
.Text = Format(TextValor.Value * TextCantidad.Value, "#.00")
.ParagraphFormat.Alignment = wdAlignParagraphRight
End With




--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
 

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