Combining workbook sheets
This page combines all the sheets of a workbook into a single table. The pattern has three problems to solve:
- The query has to pick up new sheets automatically when they are added.
- Each sheet has its own header row, and those rows must not appear in the combined data.
- The column that holds each sheet’s name has to keep working when sheets are added or their order changes.
1. Connect to the workbook
Section titled “1. Connect to the workbook”In this example, a workbook holds order data, with one sheet per month and a spare sheet, Sheet6, at the end:

- Open a new workbook.
- On the Data tab, choose Get Data ➔ From File ➔ From Workbook.

- Browse to the workbook, and in the Navigator click Transform Data without selecting a sheet.

The query lists every sheet in the workbook, one per row:

Because the query lists whatever sheets the workbook holds, a sheet added later appears on the next refresh, which solves the first problem.
2. Use each sheet’s first row as headers
Section titled “2. Use each sheet’s first row as headers”- Edit the formula of the Source step so that its second argument is
trueinstead ofnull:
= Excel.Workbook( File.Contents("C:\....worksheets.xlsx"), true, true)The second argument of Excel.Workbook says whether to use the first row of each sheet as its column headers. With it set to true, each sheet’s table arrives with its headers already promoted, so the header rows are not combined into the data, which solves the second problem.
3. Filter out the sheets you do not need
Section titled “3. Filter out the sheets you do not need”- Filter the Name column to keep the rows where it does not begin with Sheet, which removes Sheet6.

- Remove every column except Name and Data:

4. Expand the data
Section titled “4. Expand the data”- Click the expand button in the Data column’s header, and keep all the columns ticked:

The sheets are now appended into one table, with no repeated header rows, and the Name column shows which sheet each row came from:

- Rename the Name column to something more meaningful, such as Month. The rename refers to the column by its name, so it keeps working whatever sheets the workbook holds and in whatever order, which solves the third problem.