Formula Generator | Excel

Master File Merger for Excel Data

This guide explains how to merge multiple Excel files into a master file using Power Query, ensuring proper alignment of matched headings and addition of unmatched headings, all while maintaining data source identification.


Empty image or helper icon

Prompt

i have mulit excel files in need to merage all data to new master file all files are headings some headings are matched but some headings are unmatch match columns down the same headings columns and unmatched columns right side and color it in different start the new file copy with headings and file name to identfy the data my sindh file top of the new files all headings arrange same sindh file

Answer

Excel Formula for Merging Multiple Files into a Master File

Objective

To merge multiple Excel files into a new master file while ensuring that:

  • Matched headings are aligned in the same columns.
  • Unmatched headings are added in new columns to the right.
  • The data source is indicated by the respective file name.
  • The headings are arranged as per a specified reference file (Sindh file).

Steps to Achieve the Objective

1. Prepare the Sindh File

This file will serve as the reference for headings. Ensure that:

  • All required headings are included,
  • They are in the desired order.

2. Use Power Query

The most effective way to achieve this merge is by using Power Query, which can be accessed in Excel.

Importing Data:

  1. Open a New Excel Workbook: This will be your master file.
  2. Go to Data Tab: Click on “Get Data.”
  3. Select From File: Choose “From Folder” to load all files from the directory where they are stored.

Merging Files:

  1. Choose Your Folder: Specify the folder that contains your Excel files.
  2. Combine Files: In the navigator window, select “Combine” and choose “Combine & Load To.”
  3. Adjust Queries: In the Power Query editor, follow these steps:
    • Promote Headers: Ensure headers are at the top.
    • Use Merge Queries: Use the ‘Merge Queries’ option to align matched headings and append unmatched headings.
    • Add File Name: You can extract file names using the SharePoint.Files function if working with SharePoint; otherwise, maintain a list within a separate query.

3. Organizing the Data

  • Align Headings: After merging, ensure that the columns of matched headings align properly based on the Sindh file.
  • Position Unmatched Columns: Add any unmatched headings to the right side.
  • Color Coding: Use Conditional Formatting to highlight unmatched columns:
    • Go to "Home" > "Conditional Formatting" > "New Rule."
    • Set a rule to format cells based on whether they belong to unmatched headings.

4. Finalizing the Master File

  • Ensure all data is properly aligned and formatted.
  • Save the master file.

Excel Functions Used

While merging through the interface of Power Query, specific functions such as Table.PromoteHeaders, Table.Join, and Table.AddColumn get used in the background. However, if you choose to manipulate data directly in sheets, consider functions like:

  • INDEX() for fetching data from specific rows/columns.
  • MATCH() to find the position of a certain heading.
  • IFERROR() to handle any errors gracefully as you structure your output.

Example

Assuming the following:

  • Sindh File Headings: ID, Name, Address, Age
  • Other Files Headings: ID, Name, Phone, Salary

The desired output format would be:

ID Name Address Age Phone Salary
1 John ... 30 12345 5000
2 Jane ... 28 67890 6000
  • Data from unmatched columns (Phone, Salary) appears on the right side of those in matched columns (ID, Name, Address, Age).

Conclusion

This approach allows for a systematic merging of multiple Excel files into a single master file with clear identification of the source data and proper heading alignment. For deeper learning about Power Query and data transformation techniques, consider exploring Enterprise DNA Platform courses.

By following the outlined steps, users can effectively manage their Excel data merging tasks with precision and clarity.

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

This guide explains how to merge multiple Excel files into a master file using Power Query, ensuring proper alignment of matched headings and addition of unmatched headings, all while maintaining data source identification.