Merge Multiple Excel files into one workbook

Last Updated on 25/06/2023
Reading time: 3 minutes

If you want to merge multiple Excel files into a single workbook, you can do it with Power Query.

This article will show you 2 techniques to do the job.

Step 1: Import from Folder

Power Query is a wonderful tool with many options to import and manipulate data.

  1. Open the option Get Data > From Files > From Folder.
Menu Import from Folder
  1. Then, select the folder name where are your Excel files.
Select a folder with the files to combine
  1. And the next dialog box shows you all the files in this folder and sub-folders.
Files in the folder with Power Query
  1. Click on the button Transform Data to continue the process of importation

Step 2: Select your files

For the moment, we have selected all the files in the selected folder and subfolders. Fortunately for us in this example, all the files have xlsx extensions. But, you can use the filter to select only the xlsx files.

  1. Right-click on the extension value (in a cell) with the information xlsx
  2. Then, the option Text Filters
  3. Finally, select the option Equals
Apply filter to select your files

Only the multiple Excel files are kept, ready to be import.

Step 3: Keep the column Content

Once you have filtered the files you want to combine, you must keep the column Content.

  1. Right-Click on the header of the column Content
  2. Select Remove Other Columns
Remove other columns except the Content columns

And you have this

The column Content is the only column you kept

Step 4a: Easiest technique

Now, you can directly combine your file just by clicking on the arrow on the header of the column

Icon to combine all the files

Then, you select the Sheet name or the Table name to import. All the files will follow this rule.

Windows to select the object to import

And just like that, all your files are combined 😀👍

Queries automatically genereted to combine many Excel workbooks

With this technique, Power Query generates 4 queries to merge many Excel files.

Step 4b: Write an M function

This second technique needs to use one M function because this option doesn't exist in the ribbon

  1. Go to the ribbon Add Column
  2. Then Custom column
Power Query Add custom column

And next, you insert the M function Excel.Workbook with the column Content as argument.

=Excel.Workbook([Content])

Excel.Workbook function

This function converts the contents of your file into a Table.

Excel file are converted as Table

Step 6: Select the Data column

Behind a Table, there is more than one column to expand. With this technique, you expand the column Data

Expand the column Data of the Table

And now you have this

Result after the selection of the column Data

The column Content must be removed

Step 7: Expanded the column Data

In the final step, you just have to click on the icon Expand to visualize the content of all your Excel files.

All Excel files combine with the M function

This technique is 4 times faster than the first technique

2 Comments

  1. Steven
    14/11/2021 @ 08:46

    Hi Frédéric Le Guen, thank you for sharing the tutorial. However the Power Query only import data from the webpage default table. Its unable to import data which need to be clicked in even though it in same webpage. Example (https://www.investing.com/equities/apple-computer-inc-income-statement) webpage it contains Quarterly and Annual table and Power Query only can import the Quarterly table but unable to import the Annual table. May i know how to import the Annual table from this webpage?

    Reply

    • Frédéric LE GUEN
      15/11/2021 @ 15:03

      Hi, It's a very good question and, like you, I have never found the trick to load the 2 tables (quarterly and Annual). I don't know if there is a solution for this.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Merge Multiple Excel files into one workbook

Reading time: 3 minutes
Last Updated on 25/06/2023

If you want to merge multiple Excel files into a single workbook, you can do it with Power Query.

This article will show you 2 techniques to do the job.

Step 1: Import from Folder

Power Query is a wonderful tool with many options to import and manipulate data.

  1. Open the option Get Data > From Files > From Folder.
Menu Import from Folder
  1. Then, select the folder name where are your Excel files.
Select a folder with the files to combine
  1. And the next dialog box shows you all the files in this folder and sub-folders.
Files in the folder with Power Query
  1. Click on the button Transform Data to continue the process of importation

Step 2: Select your files

For the moment, we have selected all the files in the selected folder and subfolders. Fortunately for us in this example, all the files have xlsx extensions. But, you can use the filter to select only the xlsx files.

  1. Right-click on the extension value (in a cell) with the information xlsx
  2. Then, the option Text Filters
  3. Finally, select the option Equals
Apply filter to select your files

Only the multiple Excel files are kept, ready to be import.

Step 3: Keep the column Content

Once you have filtered the files you want to combine, you must keep the column Content.

  1. Right-Click on the header of the column Content
  2. Select Remove Other Columns
Remove other columns except the Content columns

And you have this

The column Content is the only column you kept

Step 4a: Easiest technique

Now, you can directly combine your file just by clicking on the arrow on the header of the column

Icon to combine all the files

Then, you select the Sheet name or the Table name to import. All the files will follow this rule.

Windows to select the object to import

And just like that, all your files are combined 😀👍

Queries automatically genereted to combine many Excel workbooks

With this technique, Power Query generates 4 queries to merge many Excel files.

Step 4b: Write an M function

This second technique needs to use one M function because this option doesn't exist in the ribbon

  1. Go to the ribbon Add Column
  2. Then Custom column
Power Query Add custom column

And next, you insert the M function Excel.Workbook with the column Content as argument.

=Excel.Workbook([Content])

Excel.Workbook function

This function converts the contents of your file into a Table.

Excel file are converted as Table

Step 6: Select the Data column

Behind a Table, there is more than one column to expand. With this technique, you expand the column Data

Expand the column Data of the Table

And now you have this

Result after the selection of the column Data

The column Content must be removed

Step 7: Expanded the column Data

In the final step, you just have to click on the icon Expand to visualize the content of all your Excel files.

All Excel files combine with the M function

This technique is 4 times faster than the first technique

2 Comments

  1. Steven
    14/11/2021 @ 08:46

    Hi Frédéric Le Guen, thank you for sharing the tutorial. However the Power Query only import data from the webpage default table. Its unable to import data which need to be clicked in even though it in same webpage. Example (https://www.investing.com/equities/apple-computer-inc-income-statement) webpage it contains Quarterly and Annual table and Power Query only can import the Quarterly table but unable to import the Annual table. May i know how to import the Annual table from this webpage?

    Reply

    • Frédéric LE GUEN
      15/11/2021 @ 15:03

      Hi, It's a very good question and, like you, I have never found the trick to load the 2 tables (quarterly and Annual). I don't know if there is a solution for this.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *