+ Reply to Thread
Results 1 to 7 of 7

Mail Merge to Separate Document but Group by Common Cell

  1. #1
    Registered User
    Join Date
    01-26-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2010
    Posts
    4

    Mail Merge to Separate Document but Group by Common Cell

    Hello,
    I have this work project I need help with. I need to generate a letter for each employee asking them to verify their mailing address that the company has on file. A sample letter is attached as well sample data (that has been anonymized). The letter each employee will receive has several merge fields to personalize the letter to the employee.

    I'm trying to do a mail merge to separate files, per store. For example, Store 1 will get one document with all their employees' letters. There are a total of about 6,000 employees across about 50 stores. I plan to email each store manager their one document for their locations to print and handout to their employees.

    I tried using the Many to one solution. It does create separate documents per store, but it only completed the first record for that store. So each document created per store, only has one employee letter.

    I apologize if this a solution was already posted, I tried searching all the different terms I can think of, but couldn't find anything. Thank you for your help.
    Attached Files Attached Files

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Mail Merge to Separate Document but Group by Common Cell

    In Your workbook, create a sheet named 'Stores' having a list of stores. Then add the following macro to your workbook and run the merge from that.
    Please Login or Register  to view this content.
    When you're satisfied the code is working correctly, you can change:
    wdApp.Visible = True
    to:
    wdApp.Visible = False

    Note: The macro assumes your 'Test Letter' and your workbook are stored in the same folder - which also where the output will go. Naturally, since your actual mailmerge main document and mailmerge sheet names are unlikely to be named 'Test Letter' and 'Sheet1', respectively, you'll need to change those names in the code, too. And, if you already have another worksheet in the same workbook that has a store listing, you might use that instead of creating a 'Stores' worksheet - but you'll also need to change that sheet reference in the code.
    Last edited by macropod; 03-31-2020 at 02:47 AM.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    01-26-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2010
    Posts
    4
    Thanks for the help. I'm a little by confused. Should I be running the merge like normal through Word or a different way. I try to run macro & getting the attached error. Should I save the test data as a macro enabled workbook first?

    I couldn't upload image of error
    Compile error:
    User-defined type not defined

    It selected "wdApp As New Word.Application"
    Last edited by neimad14; 03-12-2020 at 10:19 PM.

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Mail Merge to Separate Document but Group by Common Cell

    As I said:
    Quote Originally Posted by macropod View Post
    add the following macro to your workbook and run the merge from that.
    There is nothing attached to your post. Ideally, you would save the workbook as a macro enabled one before running the macro, but that's not strictly necessary. Pay attention, too to the note at the top of the macro.

  5. #5
    Registered User
    Join Date
    01-26-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Mail Merge to Separate Document but Group by Common Cell

    Quote Originally Posted by macropod View Post
    As I said:

    There is nothing attached to your post. Ideally, you would save the workbook as a macro enabled one before running the macro, but that's not strictly necessary. Pay attention, too to the note at the top of the macro.
    Thanks. I overlooked that note. Now it partially completes the merge. It stops after the first three stores.

  6. #6
    Registered User
    Join Date
    01-26-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2010
    Posts
    4
    I figured it out. This line "For r = 2 To 4" was causing the issue. I changed the 4 to the row number of the last store name.

    Thanks for your help!

  7. #7
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Mail Merge to Separate Document but Group by Common Cell

    I don't know where the 4 came from, it's supposed to be lRow. Corrected.
    Last edited by macropod; 03-31-2020 at 02:47 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Export Mail Merge Document into PDF
    By alopecito in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-30-2018, 03:10 AM
  2. Group Fields in Mail merge based on common field
    By Sinon05 in forum Word Formatting & General
    Replies: 2
    Last Post: 03-04-2016, 01:46 AM
  3. Replies: 0
    Last Post: 06-24-2015, 02:34 AM
  4. Mail merge to Word Document
    By Banaticus in forum Excel General
    Replies: 8
    Last Post: 08-08-2013, 04:28 AM
  5. Print mail merge document
    By LisaPatch in forum Excel Programming / VBA / Macros
    Replies: 31
    Last Post: 10-31-2011, 09:54 AM
  6. Mail merge, group rows
    By mickyjune26 in forum Excel General
    Replies: 1
    Last Post: 04-24-2007, 07:45 AM
  7. [SOLVED] Open a mail merge from excel: common problem
    By lightspeed in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-21-2006, 09:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1