Mail Merge from Excel to Word Breaking to new document based on column entry

cheesiepoof05

Board Regular
Joined
Dec 30, 2010
Messages
82
Hello all,

I am working on creating a mail merge document process from Excel to Word that splits based off of a 1 indicator in a certain column. Certain fields need listed all under the same document but change in length for row count. I thought it might be easier to create a short sample of what I'm doing. So the example below would create three different documents. With each one listing the class at the top and then a list of Animals and Colors below it. I appreciate your help. I'm trying to avoid any 3rd party addins if at all possible, but wasn't sure if Excel/Word had this ability inherently. Thanks!

[TABLE="width: 555"]
<tbody>[TR]
[TD]
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]File_Name
[/TD]
[TD]New_Record
[/TD]
[TD]Class
[/TD]
[TD]ANIMAL
[/TD]
[TD]COLOR
[/TD]
[/TR]
[TR]
[TD]MAMMALS - 20170419
[/TD]
[TD]1
[/TD]
[TD]MAMMALS
[/TD]
[TD]DOG
[/TD]
[TD]BROWN
[/TD]
[/TR]
[TR]
[TD]MAMMALS - 20170419
[/TD]
[TD][/TD]
[TD]MAMMALS
[/TD]
[TD]MOOSE
[/TD]
[TD]BROWN
[/TD]
[/TR]
[TR]
[TD]MAMMALS - 20170419
[/TD]
[TD][/TD]
[TD]MAMMALS
[/TD]
[TD]MOOSE
[/TD]
[TD]GRAY
[/TD]
[/TR]
[TR]
[TD]MAMMALS - 20170419
[/TD]
[TD][/TD]
[TD]MAMMALS
[/TD]
[TD]RABBIT
[/TD]
[TD]WHITE
[/TD]
[/TR]
[TR]
[TD]MAMMALS - 20170419
[/TD]
[TD][/TD]
[TD]MAMMALS
[/TD]
[TD]ZEBRA
[/TD]
[TD]STRIPE
[/TD]
[/TR]
[TR]
[TD]BIRDS - 20170419
[/TD]
[TD]1
[/TD]
[TD]BIRDS
[/TD]
[TD]CARDINAL
[/TD]
[TD]RED
[/TD]
[/TR]
[TR]
[TD]BIRDS - 20170419
[/TD]
[TD][/TD]
[TD]BIRDS
[/TD]
[TD]BLUE JAY
[/TD]
[TD]BLUE
[/TD]
[/TR]
[TR]
[TD]BIRDS - 20170419
[/TD]
[TD][/TD]
[TD]BIRDS
[/TD]
[TD]WOOD PECKER
[/TD]
[TD]BROWN
[/TD]
[/TR]
[TR]
[TD]REPTILES - 20170419
[/TD]
[TD]1
[/TD]
[TD]REPTILES
[/TD]
[TD]LIZARD
[/TD]
[TD]GREEN
[/TD]
[/TR]
[TR]
[TD]REPTILES - 20170419
[/TD]
[TD][/TD]
[TD]REPTILES
[/TD]
[TD]SNAKE
[/TD]
[TD]YELLOW
[/TD]
[/TR]
[TR]
[TD]REPTILES - 20170419
[/TD]
[TD][/TD]
[TD]REPTILES
[/TD]
[TD]KOMODO
[/TD]
[TD]GREEN
[/TD]
[/TR]
[TR]
[TD]REPTILES - 20170419
[/TD]
[TD][/TD]
[TD]REPTILES
[/TD]
[TD]CHAMELEON
[/TD]
[TD]MIXED
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]
[/TD]
[/TR]
</tbody>[/TABLE]


Mail Merge Sample (please note while the list part doesn't appear to be in a grid, I will need it to be.)
For the animal class of «CLASS»
«ANIMAL»
«Color»

<tbody>
</tbody>



Mail Merge Sample for first document

For the animal class of MAMMALS
DOG
Brown
MOOSE
Brown
MOOSE
Gray
RABBIT
White
ZEBRA
Striped

<tbody>
</tbody>
 
Last edited:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
You can use Word's Catalogue/Directory Mailmerge facility for this (the terminology depends on the Word version). To see how to do so with any mailmerge data source supported by Word, check out my Microsoft Word Catalogue/Directory Mailmerge Tutorial at:
Microsoft Word Catalogue/Directory Mailmerge Tutorial | Windows Secrets Lounge
or:
http://www.gmayor.com/Zips/Catalogue Mailmerge.zip
The tutorial covers everything from list creation to the insertion & calculation of values in multi-record tables in letters. Do read the tutorial before trying to use the mailmerge document included with it.

The field coding for this is complex. However, since the tutorial document includes working field codes for all of its examples, most of the hard work has already been done for you - you should be able to do little more than copy/paste the relevant field codes into your own mailmerge main document, substitute/insert your own field names and adjust the formatting to get the results you desire. For some worked examples, see the attachments to the posts at:
mail merge with duplicate names but different dollar amounts
Access to Word, Creating a list from multiple records
Word 2010 Merge from excel into Table Directory | Windows Secrets Lounge

Another option would be to use a DATABASE field in a normal ‘letter’ mailmerge main document and a macro to drive the process. An example of this approach can be found at: http://answers.microsoft.com/en-us/...g-tables/8bce1798-fbe8-41f9-a121-1996c14dca5d
The DATABASE field can even be used without recourse to a mailmerge. An example of such usage can be found at: Mail merge into different coloumns

Although none of the above specifically creates a new document at each break, post-merge you could run the Split Merged Output to Separate Documents macro in the Mailmerge Tips and Tricks thread at:
http://www.msofficeforums.com/mail-merge/21803-mailmerge-tips-tricks.html
or:
http://windowssecrets.com/forums/showthread.php/163017-Word-Mailmerge-Tips-amp-Tricks
If you use the DATABASE field approach, the macro that drives that could be combined with the Send Mailmerge Output to Individual Files macro code in these last two links to generate separate documents for each group as part of the merge process.

Alternatively, notwithstanding your reservations about 3rd-party addins, you may want to try one of the Many-to-One Mail Merge add-ins, from:
Graham Mayor at http://www.gmayor.com/ManyToOne.htm; or
Doug Robbins at http://bit.ly/1hduSCB

In addition to a 'Many to One' merge, the latter handles:
• Merge with Charts
• Duplex Merge
• Merge with FormFields
• Merge with Attachments
• Merge to Individual Documents
• Merge, Print and Staple
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,793
Messages
6,174,635
Members
452,575
Latest member
Fstick546

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