presenting number copied excel

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Presenting a number that is copied from Excel to Word

Presenting a number that is copied from Excel to Word

resolvedResolved · Low Priority · Version 2013

Presenting a number that is copied from Excel to Word

I'm trying to copy some numbers from an Excel table to a Word table using a Macro in Excel. One of the numbers is 0.020 but when it's copied it is rounded to 0.02. How can I present the number as 0.020?

Thanks.

RE: Presenting a number that is copied from Excel to Word

Hi Rita,

Thank you for the forum question.

I hope the 3 days of Excel where useful and thank you for the nice feedback.

Have a look at the code below. I have just added the Format function in two lines. Otherwise it is exactly the same code as we did yesterday.



Sub CreateCert()

Dim wApp As Word.Application
Dim wDoc As Word.Document
Dim tblTable As Word.Table
Dim iCounter As Integer



Set wApp = CreateObject("Word.Application")
wApp.Visible = True

Set wDoc = wApp.Documents.Open("C:\Users\jens\Desktop\Excel for scientist\Certificat.dot")
Set tblTable = wDoc.Tables(1)
With wDoc



For iCounter = 1 To 4


tblTable.Cell(2, 1 + iCounter).Range.Text = Format(Round(Cells(17, 2 + iCounter).Value, 3), "0.000")

tblTable.Cell(3, 1 + iCounter).Range.Text = Format(Round(Cells(23, 2 + iCounter).Value, 3), "0.000")


Next iCounter


.SaveAs2 Filename:=("C:\Users\jens\Desktop\Excel for scientist\test2.docx"), _
FileFormat:=wdFormatXMLDocument, AddtoRecentFiles:=False
.Close

End With

wApp.Quit

End Sub









Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Thu 13 Apr 2017: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

##### displaying in Excel

When you get a series of hash symbols (####) appearing in some of your cells in a spreadsheet, this can make you think that you've make some kind of mistake.

This is a common misconception - what this actually means is that the cell is not wide enough to fully display the content of the cell.

All you need to do to see what is actually in the cell is to widen the column that the cell is in.

View all Excel hints and tips


Server loaded in 0.05 secs.