“Eventually, all things merge into one, and a river runs through it.”
April 6, 2006 3:32 PM   Subscribe

Complex Excel to Word merge question is the

Its going to be difficult to explain this clearly, so bear with me.

I have two Excel files I need to merge into one (long) Word document.

The first file is a straightforward merge: Names and addresses and such. Each one of these (lets call them the Customer Records) are tagged with a specific, unique, numeric ID. There are 400+ customer records.

The second file is more complex: It is a list of purchases made by the customers. Some customers have made dozens of purchases, some only one or two. Each customer purchase has the unique customer record ID attached, plus other information. There are 3000+ purchase records for these 400+ customer records.

The output that I want is:
A single customer's contact information and buying history on a single word document page, then a page break, the next customer, and so on for 400+ pages.

So imagine

customer ID
Name
Address
email
telephone
comment

purchase 1 data (date, amount, product)
purchase 2 data (date, amount, prodcut)
purchase 3 data (date, amount, product)

[page break]

Next customer record

... and so on -- but remember that some customers have 20+ purchases and some have only one.

I'm all good with the Name, address, merge part -- the part that is stumping me getting only the purchase data that is tied to that specific cusomer ID on the page I want it.

Is there some way within the Word Merge function to tie the Customer ID in the name/address record to the Customer IDs listed in the purchase record, so that only the customer purchases that are tied to that customer ID appear on each page? In a database program I would do this by creating a form with a repeating pannel, but that isn't an option here.

My predecessor in this job, who was largely incompetent in may respects, managed to create an output like this, and I am taking a lot of abuse for not being able to replicate her results. Unfortunately, I only have hard copy of her output, not any electronic copy I can reverse engineer.

Its possible that she did the whole thing by hand, as a copy/paste back and forth from Word to Excell and back again, but the sales director swears that "she just pressed a button" and it all merged together.

I can change the Excel to .txt or .dbf or other formats if I need to, but the output must be in a Word document.

I'm going to a meeting, but will reply to any questions in a few hours when I return.

Thanks for your help!
posted by anastasiav to Computers & Internet (10 answers total)
 
I have done something similar to this before by working out the maximum number of (in this case) purchases per customer, and having that many fields for purchases in the merge doc. Then ensure those fields are set to "Skip field if blank".

You would then need to lay out your data source so each row is like Name, Address etc, Purchase1_field1, Purchase1_field2 ... Purchase1_fieldn, Purchase2_field1, etc. This may be a pig, but you may be able to do a lot of it with a few paste-special-transposes.
posted by pompomtom at 4:54 PM on April 6, 2006


As far as i know, there is no built-in way for microsoft word to handle two different data sources - you'll have to put all the data in one table. There are two things you're going to have to do to make this work:

1) Combine the data somehow. I don't know how to do this in excel but i know how to do it in access. I can help you out with this if you like. You want it to be one big table with all the data, with columns like:

customerID, customerName, orderNumber, amount

basically, you're just adding a few columns onto the "purchases" table: one for the customer name, one for address and such. There will be lots of redundant data, but that's okay.

2) Use the following method to break it up for one customer on each page with multiple purchases.

http://support.microsoft.com/?kbid=211303

Hope it helps.
posted by escher at 4:58 PM on April 6, 2006


It definitely sounds like the kind of thing you can do with the Data Merge Manager which has a bewildering number of options and buttons.

Just experimenting, I've got Word's merge features to open an excel spreadsheet and using "Query Option" to say it should merge only the data where "customer number" is equal to 1, for instance, so the only missing piece is getting it to match, not a hard-coded 1, but a value from the other sheet.

Alternative approach -- who was your predecessor's pal at the company? It sounds like someone with more skills than her set the thing up for her. Find that person and ask them how it's done?
posted by AmbroseChapel at 5:00 PM on April 6, 2006


Didn't preview. Maybe it's not possible. Sorry to have misled you.
posted by AmbroseChapel at 5:02 PM on April 6, 2006


Here's what I would do: import the two data files into one MS Access file (.mdb) as two tables 'customers' and 'purchases'. Set the customerID in the 'customers' table as the primary key for that table. Let Access add a primary key to the 'purchases' table. Go into Tools|Relationships and add both tables. Click the customerID field in the 'customers' table and drag it over to the customerID in the 'purchases' table to create a 'one to many' relationship. Save and close the relationships tool. Play with the Reports wizard to see if you can use one of the standard reports to do produce the look you want. Once you get a report in Access working you should be able to convert it to word using a button in the Tools menu that says 'Report this in MS Word' or somesuch. I'm doing this off the top of my head and I totally hope I didn't miss something in reading your situation description. If I heard you right though, this is the way to get the job done.

Good luck.
posted by kaytrem at 5:21 PM on April 6, 2006


kaytrem's solution is the one I had in mind. It should work.
posted by beelzbubba at 5:25 PM on April 6, 2006


What kaytrem said, definitely! This is *easily* done in Access, and that's the place that distributed data like yours should reside anyway, not in a flat file setup like Excel.
posted by jasper411 at 9:04 PM on April 6, 2006


I would use the VLOOKUP function in excel to add the data from your first sheet to your second sheet. I would then use pivot tables to get a summary list by client. I'm generally pretty happy just having the data in Pivot tables, but it should be pretty easy to break that out into a way that you can import it easily into Word.

People tend to be really confused by VLOOKUP and Pivot tables, but once you get the hang of them, they're crazy simple and very powerful for this kind of thing.

I'm sure you can find a good help file for using this stuff with a Google search, but let me know if you need a walk through.
posted by willnot at 10:27 PM on April 6, 2006


Access is the tool for this job, if you want to keep the data in Excel you can Link/Attach the two spreadsheets and work with them in Access.
posted by Lanark at 3:23 AM on April 7, 2006


I'm so sorry to say it, but Access is going to do this for you. It's kind of a b*tch of a program to learn, but you probably DO have it on your computer somewhere, and you can 'Import' your existing spreadsheets into a new database.

It *will* take a while to learn how to set things up in Access, but once you do, you'll look like a wizard with all the stuff you'll be able to produce. The 'Report' that you make can easily be Exported to Word.

I suggest that if you choose to attempt Access, start with a Template database. I think the "Order Entry" one will work for you.
posted by Sprout the Vulgarian at 6:57 AM on April 7, 2006


« Older More private alternatives to del.icio.us   |   At least I know where the *big* hand is... Newer »
This thread is closed to new comments.