Create a Pivot Table using data from different sheets in a workbook, or from different workbooks, if those tables have identical column structures.
April 12th - 18th: Free webinar, Mastering Pivot Tables -- Learn how to set up data and create a Pivot Table in less than 3 minutes. Create an interactive dashboard with Slicers & Pivot Charts. Show key business metrics, and much more. Click here to pick a date and time: Free PivotTable Webinar
To create a Pivot Table, you can use data from different sheets in a workbook, or from different workbooks, if those tables have identical column structures.
However, you won't get the same pivot table layout that you'd get from a single range, as you can see in the screen shot below.
If possible, move your data to a single worksheet, or store it in a database, such as Microsoft Access, and you'll have more flexibility in creating the pivot table.
If combining your data isn't an option, this pivot table tutorial explains the steps to create a pivot table from multiple consolidation ranges, describes the limitations, and suggests workaround solutions.
A pivot table appears on the worksheet, with the first field in the Row area, and all of the other fields from the source data in the Values area, showing a Count.
All of the fields from the source data are included in the multiple consolidation pivot table, so you can remove some of them, and make a few other changes.
In this example, the Colour, Date, Price and Rep fields contain text, or numbers that are meaningless in this report, so they will be removed.
By default, the Values will show as Count, and you can change that to Sum, or another calculation.
NOTE: This will affect all of the Values -- they cannot be changed separately.
The Grand Total for Rows is meaningless in this report, because it is showing the total for unrelated items, so it should be removed..
In the pivot tables, generic fields are created -- Row, Column, Value and Page1. You can rename those fields, to make the pivot table easier to understand.
The labels have been changed in the screen shot shown below. The Column Labels heading was replaced by a space character.
By default, the pivot table has the Compact Report Layout, and you can change that to Outline, so each Row field will be in a separate column. Then, move the Page field into the Row area, above the existing Row field.
To see the steps for creating a pivot table from data on different sheets, what this multiple consolidation ranges pivot table video tutorial.
In this example, Item is the first column in the data source, and the pivot table row heading shows the item names. Remaining fields are shown in the column area.
To avoid the limitations of multiple consolidation ranges, you can try one of the following alternatives.
If you have a version of Excel that supports Microsoft's Power Query add-in, you can use it to combine the data in two or more tables. The tables can be in the same workbook, or in different files.
The tables can have different structures, and should have some columns with identical headings, in which the data can be combined. In this example, the East and West region data will be combined, and one column is unique in each table.
To follow this video tutorial, download the sample file from the section below.
If you can't combine your data on a single worksheet, another solution is to create named ranges in an Excel file, and use Microsoft Query (MS Query) to combine the data. There are sample files here: http://www.contextures.com/excelfiles.html#PT0007
Then, use the Union query (full outer join) result as the pivot table's source data.
With this solution, you'll end up with a normal pivot table, with none of the limitations. However, it's a bit tedious to set up, especially if you have more than a couple of tables.
You can read more about MS Queries here:
Instead of manually setting up a union query, you can use the code in a sample file from Excel MVPs, Kirill Lapin (KL), with amendments by Héctor Miguel Orozco Diaz.
Before you use the sample code, replace the sample sheet names with the sheet names in your workbook.
For example, if your sheet names are "East" and "West", change this line of code:
arrSheets = Array ("Ontario", "Alberta")
arrSheets = Array ("East", "West")
In the code, you can also change the location where the pivot table will be added. In the sample file, the TableDestination is set for the active sheet, in range A1.
Then, after you make those small changes, click the button on the worksheet, and a summary pivot table is automatically created.
To download the sample file from Kirill and Héctor, click here: Pivot Table From Multiple Sheets.
Kirill Lapin shares his code to create a Union query and build a fully functional pivot table from data in multiple Excel files. For instructions, read the Contextures Pivot Table Blog article:
There also an example file that creates either a pivot table or a formatted Excel table from the consolidated data. Download it from the Excel Sample Files page, in the Pivot Tables Section:
Download the sample pivot table tutorial file
Last updated: May 17, 2016 3:21 PM