Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

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

ResolvedVersion 2013

Rita has attended:
O365 Digital Champions course
O365 Intermediate training PM course
PowerPoint Intermediate Advanced course

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:

Switch between workbooks ni EXCEL.

use Alt-TAB to switch between workbooks.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.