Combining worksheets is simple, but you would never accidentally discover the steps of this technique. I learned this trick from Australian author Matt Allington. There are a few requirements for this technique: Each worksheet must have the same columns in the same sequence. The trick will be simpler if the headings appear in row 1 of each worksheet. If you have some title cells in the top rows and the headings are in row 4 or 5, you’ll have to take the time to create a named range on each worksheet that starts at the headings and includes all rows of data.

The technique uses Power Query, which means you can perform the steps in a blank workbook and then refresh that workbook the next time you receive the source data from elsewhere, like a coworker. The coworker’s workbook remains unchanged, but you’ll have a worksheet that consolidates all data from all of the worksheets. (Note that Power Query debuted in Windows versions of Excel 2016 and is currently only available for Windows versions of Excel, but Microsoft is working on adding it to Excel for Mac.)

Save the workbook with multiple worksheets on your local hard drive. From a blank workbook, select Data, Get Data, From File, From Workbook. Browse and select the workbook.

A Navigator dialog appears with a list of worksheets in the workbook. This is where you would normally select one sheet and choose Transform Data. But here’s the first hidden feature: Instead, right-click on the workbook name and choose Transform Data.

The Power Query Editor opens. You should have one row for each worksheet and one row for each named range. If your data always starts in row 1, you can keep the records where the Kind column says “Sheet.” If the data starts elsewhere and you used named ranges, you should filter to remove the records where the Kind column says “Sheet.” If you have a stray worksheet that doesn’t contain data but instead contains instructions or a table of contents, use the filter drop-down in the Name column to remove that worksheet from the list.

There are five columns shown in the Power Query Editor. Once you’re done filtering, you can right-click and remove the columns for Item, Kind, and Hidden. This leaves you with what appears to be a useless list of the worksheet names with the word “Table” next to each one. The column that simply repeats the word Table in each row is secretly hiding all of the data. Look for the icon in the heading row with two arrows pointing in opposite directions.

Click the arrows to open the expand dialog. Power Query provides a generic list of Column 1, Column 2, Column 3, and so on. Make sure to uncheck the box for Use Original Column Names as Prefix and then click OK.

Finally, you have a grid showing all records from all worksheets. The headings are appearing in row 1 instead of in the headings area. On the Home tab of the Power Query Editor, choose Use First Row as Headers to move the headings up from row 1.

If you had 12 worksheets that were combined, each of the worksheets likely started out with a row of headers. After moving the headings from row 1 up to the column name, you’ll still have another 11 rows spread throughout your data with the column headings appearing again.

Open the Filter drop-down on any column and choose to remove any records that have the column name. For example, you could open the Product filter and remove “Product” or open the Customer filter and remove “Customer.” This will take care of removing the remaining heading rows from the other worksheets.

Perform any final formatting steps. Filter out any blank records by removing the value (null) from any filter drop-down. Sort the data by date. Set the Data Type on the Transform tab to Date for any date columns. Rename any columns that need to be renamed.

Finally, click the Close & Load icon on the Home tab of the Power Query Editor. All of the data from the various worksheets will load into your workbook. The best part: Next week or next month when you receive a new copy of the original workbook, simply save it with the same name in the same folder. When you open your results workbook, click the Refresh icon in the Queries & Connections panel to automatically repeat all of the steps. This is another hidden step, as the Queries & Connections panel starts out too narrow for the Refresh icon to appear. Make the panel wider to see Refresh.


SF SAYS

The steps to easily combine all sheets are easy to do but particularly hard to discover.

About the Authors