VBA code to copy table from excel to word template

LadyTiara

New Member
Joined
Feb 20, 2018
Messages
11
Hi.

I have a macro excel file that has a mail merge function with Word.
I have a total of 9 records under RESULT tab. And I have 2 Word templates where if cell AW1 is 'Inventory', then it will pick up the 'Inventory' template, else it will pick up the 'Marketing' template. I used the if and else function for this. And this goes in a loop.

Now, overall my vba code is working with a loop (9 records). However,there is one thing that I need to add to my existing code. From another tab of same excel file which is "Dates" tab, I wanted to paste the dates table as well to my Word template, provided that the chosen template picked is 'Inventory' template. If it is Marketing template, no action is done.

For example (see sample below and sorry if formatting is not in table), I have an individual template auto-generated by macro for Reference 1 and the template chosen is 'Inventory' template. With this, the dates table from 'Dates' tab should also be exported to the very last page of the 'Inventory' Word Template. Then, this goes in loop til the last record (record #9 ). The problem is I dont know the vba code for this. Mail merging cannot be done coz the record dates per reference is going vertically, (not horizontally). Could somebody help me formulate the code? Many thanks.

If there is anything that needs more clarification, pls let me know. I'm not sure if I made myself clear.


PS: Is this going to be added in Module? Just wondering.

DATES table from 'Dates' tab


Reference: 1 Reference: 2 Reference: 3 .................. Reference: 9
Expiry Setlement Expiry Setlement Expiry Setlement Expiry Setlement
15Jan17 17Jan 17 15Feb17 17Feb 17 15Mar17 17Mar 17 17Apr17 19Apr17
18Jan17 20Jan17 18Feb17 19Feb17 18Mar17 20Mar17 20Apr17 22Apr17
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,215,491
Messages
6,125,111
Members
449,205
Latest member
ralemanygarcia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top