Article ID: 211802 - View products that this article applies to.
This article was previously published under Q211802
This article describes how to use Microsoft Query to merge two Microsoft Excel 2000 files. You may want to do this so that you can combine related information into a single file and use it in a Microsoft Word mail merge.
Merging two Excel files allows you to combine related information into a single file.
For more information about creating a mail merge data source in Microsoft Excel, click Microsoft Excel Help on the Help menu, type work with a mail merge data source in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
Example: Merging Two Excel FilesOne file can contain a list of ID numbers, first names, last names, and positions, and another file can contain a list of ID numbers, addresses, and salaries.
If the ID numbers in both files are the same, you can link the two files by using the similar (or common) ID field. This allows you to create a mail merge that contains the ID numbers, first names, last names, addresses, positions, and salaries. For the files to be combined inside Microsoft Query, the files must be in the correct format in Excel. Each column of information needs a heading name (do not use spaces, quotation marks, apostrophes, or hyphens in the heading names).
In these two sample Excel files, File1, cell A1 contains the word "IDNumber," cell B1 contains the word "Firstname," cell C1 contains "Lastname," and cell D1 contains "Position." In File2, cell A1 contains the word "IDNumber," cell B1 contains "Address," and cell C1 contains "Salary."
A1: IDNumber B1: Firstname C1: Lastname D1: Position A2: 1 B2: James C2: Jones D2: Clerk A3: 2 B3: Harry C3: Anderson D3: Administration
The IDNumber column in File1 should be similar to the IDNumber column in File2. That is, the column heading should be the same, and the information in File1 should correspond to the information in File2. That is, IDNumber 1 should represent the same employee in both sheets. That is, James Jones (IDNumber 1 in File1) should live at 333 3rd Ave (IDNumber 1 in File 2). When you connect the two files using Microsoft Query, you can retrieve all of the information about James Jones into a single data source.
A1: IDNumber B1: Address C1: Salary A2: 1 B2: 333 3rd Ave. C2: $20,000 A3: 2 B3: 444 4th St. C3: $25,000
Modifying the Files in ExcelAfter the files have been created, name the ranges of information in each sheet. To do this, follow these steps:
Starting the Mail MergeTo start the mail merge, follow these steps:
Creating a Microsoft Query Data SourceTo create the Microsoft Query data source, follow these steps:
Creating the QueryTo create the query, follow these steps:
Adding the Second File and Joining the Data in Microsoft QueryTo join the data in Microsoft Query, follow these steps:
Selecting the Fields That You Want to Use in the Mail MergeTo select the fields that you want to use in the mail merge, follow these steps:
Creating the Mail Merge Main DocumentTo create the mail merge main document, follow these steps:
For additional information about mail merge and Microsoft Query, click the article numbers below to view the articles in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/212322/EN-US/ )WD2000: How to Design and Set Up Mail Merge Data
(http://support.microsoft.com/kb/212314/EN-US/ )WD2000: How to Use a Microsoft Excel Data Source for Mail Merge
(http://support.microsoft.com/kb/212329/EN-US/ )WD2000: How to Start a Mail Merge
(http://support.microsoft.com/kb/258217/EN-US/ )WD2000: Can't Connect, Insert Database with ODBC and MSQuery
Article ID: 211802 - Last Review: December 6, 2000 - Revision: 1.1