• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Microsoft Excel Tips and Tricks - Computergaga

  • Home
  • Excel Online Courses
  • Excel Functions List
  • Free Downloads
  • Blog
  • Tutorials
  • About
Home / Power Query / Import Multiple Excel Files with Multiple Sheets in Excel

Import Multiple Excel Files with Multiple Sheets in Excel

In this post, we look at how to import multiple Excel files that contain multiple sheets into one Excel table.

Importing multiple files from a folder is one of the most popular functions of Power Query. A common question I get is “what about if an Excel file had multiple sheets”.

In this post, we answer that question.

You can download the files used in the tutorial to follow along.

Watch the Video

In this scenario, we have a folder that contains four Excel workbooks. Each one with training data for months of the year.

Multiple Excel files in a folder

Each workbook has six sheets. Only four of those sheets (London, Birmingham, York and Reading) contain data that we want imported to the Excel table.

Sheets to import into Excel

Import Excel Files from a Folder

Let’s start by connecting to the folder that contains the Excel files that we need.

  1. Click Data > Get Data > From File > From Folder.
Get data from folder with Power Query
  1. Click the Browse button to locate the folder that contains the files. In the files provided the folder is named Data.
Browse to the folder that contains the files
  1. Click Transform Data on the next window which lists the contents of the folder.

The Power Query Editor opens and shows the four Excel workbooks.

There are columns displaying the file name, extension, date created and more. We only want the Content and Name columns.

  1. Select the Content column, hold Ctrl and select the Name column so they are both selected. Right click and Remove Other Columns.
Remove other columns in Power Query

Create a Custom Column to Get the Sheets Data

We now need to extract the data on the sheets of each of the workbooks in that folder. For this, we will create a custom column and use a small bit of M code. Very exciting!!

  1. Click Add Column > Custom Column.
Add a custom column in Power Query
  1. In the Custom Column window, enter GetSheets for the column name.
  1. Then enter the following formula.
=Excel.Workbook([Content],true)
Custom column to extract the sheets from each workbook

Content is the name of the header that contains the objects (sheets and tables) of the workbook. True states to use headers.

  1. Click Ok.

The additional column is added. This GetSheets column contains a table with information about the different objects of each workbook.

Custom column with a table of objects for each workbook
  1. Click the double arrow button in the GetSheets column header to extract the columns from the table. Click Ok.
Extract the objects from the table

You can now see all of the sheets and tables from each workbook in the list. Information such as the object name, kind and if it is hidden or not is shown.

Extract all sheets and tables from the workbooks

You can now filter out the sheets or tables that you do not want to use.

We will start by filtering out any tables, as we are only interested in the sheets, in this example.

  1. Click the filter arrow for the GetSheets.Kind column and uncheck the Table box. Click Ok.
Filter out the tables to only import sheet data

In this example, we also do not want all of the sheets. We want to exclude the Lists and Summary sheets from the data import.

  1. Click the filter arrow for the GetSheets.Item column and uncheck the Lists and Summary boxes. Click Ok.
Filter to select the sheets you want to include in the import

We can now remove any columns that we do not want. In this example, we will remove the Content, Name, Item, Kind and Hidden columns.

  1. Click on the Content column, then hold Ctrl and click the other columns. Right click and Remove Columns.

The Name column is often useful to keep, but in this example we have the date on the sheets, so the Name column offers us nothing useful.

We are left with just the sheet name and data columns.

Sheet name and data columns only

Extract the Sheets Data

We can now extract the data for the sheets of each workbook.

  1. Click the double arrow button on the GetSheets.Data column.
  2. We will extract all of the columns but uncheck the Use original column name as prefix box.
Extract the sheet columns

We now have all the data from those sheets and for each workbook.

Sheet data from each workbook in the folder

To finish, we will do some final Power Query checks and changes.

  1. Change the column header from GetSheets.Name to Venue.
  2. Change the data types, Venue to Text, Course to Text, Date to Date and No of Delegates to Whole number.
Change the column data types
  1. Click Home > Close & Load list arrow > Close & Load To.
  2. Choose where you want to load the data. In this example, I will load it to a Table on the Existing Worksheet in range A1.
Load data to a table on an existing sheet

This completes the mission of importing data from multiple sheets and from multiple Excel files.

We can now continue our analysis on this data easily with formulas, PivotTables and other Excel magic.

Related Posts:

  • SWITCH function feature
    Excel SWITCH Function - Nested IF Function Alternative
  • Calculate age in Excel thumbnail
    How to Calculate Age in Excel
  • N Functions in Excel thumbnail
    N Function in Excel
  • Live currency exchange rate in Excel thumbnail
    LIVE Currency Exchange Rate in Excel

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

Recent Posts

  • Excel SWITCH Function – Nested IF Function Alternative
  • Sum Formulas Only in Excel
  • How to Calculate Age in Excel
  • Custom Sort in Excel
  • Case Sensitive Lookup with XLOOKUP in Excel
Advanced Excel Success book

Footer

Contact

[email protected]

LinkedIn Twitter YouTube

Useful Links

  • Home
  • Excel Online Courses
  • Tutorials
  • Sitemap
  • Privacy Policy
  • Jobs by Jooble

Course Topics

  • Blog
  • Charts
  • Courses
  • Dashboards
  • Downloads
  • Excel Tips
  • Formulas
  • Mail Merge
  • Office
  • PivotTables
  • Power BI
  • Power Pivot
  • Power Query
  • VBA

Join Our Mailing List

© Copyright 2009 Computergaga · All Rights Reserved ·