Create Pivot Table or Excel Table from Multiple Files

Excel Table from Multiple Files

A few years ago, Excel MVP Kirill Lapin shared his code to create a pivot table from identically structured tables in two or more Excel files. His technique used a Union query in Microsoft Query, and you can see the details here.

You just click the button to start the macro.

worksheet button to run macro
worksheet button to run macro

Then, select the files that you want to include (press the Ctrl key, and click on multiple files)

select files to include
select files to include

Pivot Table Created

A pivot table is created from all the data, and you can filter or sort the data, just as you would in any other pivot table.

pivot table created from files
pivot table created from files

Create an Excel Table Instead

Instead of building a pivot table from the data, a few people asked if it was possible to create a worksheet table instead.

So, I created a variation on Kirill’s macro, and I’ve uploaded a new version of the file. Now it has two “Create” buttons on the main sheet:

  • one to create a pivot table, and
  • one to create an Excel table.
worksheet buttons to run macros
worksheet buttons to run macros

Clear Sheet to Start Over

I also added a Clear Sheet button, to remove whatever is on the sheet, in case you want to start fresh.

Clear Sheet button on worksheet
Clear Sheet button on worksheet

Download the Sample File

To download the new version of the sample file, please visit the Excel Sample Files page on my Contextures site. In the Pivot Tables section, look for PT0033 – Pivot Table or Excel Table from Multiple Files

The zipped file contains a folder with region files and the master file – Report.xlsm. The master file contains macros, so be sure to enable those if you want to test the macros.

_____________________

0 thoughts on “Create Pivot Table or Excel Table from Multiple Files”

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.