Combining Excel Workbooks Is Easier Than You Think With This Powerful Tool

Stacking data from multiple worksheets manually can be painfully time-consuming and could easily lead to copying errors. What’s more, this process becomes even more burdensome if you need to regularly update the dataset. Luckily, Excel’s Power Query tool can do all this for you.

Although this guide explains how to pull information from various XLSX files, you can follow a similar process with TXT, CSV, and XML files.

Step 1: Organize the Workbooks You Are Going to Combine

Before you begin combining Microsoft Excel files into one worksheet, there are some important steps to take.

First, make sure all the datasets you’re going to combine are structured in the same way. Specifically, they must contain the same number of columns, have the same column headers, and the worksheet tabs must have the same name. Also, the process will be much more straightforward if the file names follow a similar syntax.

Two Excel workbooks with similar names, and their respective worksheets have the same columns and tab identifications.

That said, the columns don’t need to be in the same order, and the number of rows on each sheet can differ.

Second, ensure the files are saved in the same folder.

A folder in Windows 11 containing three Excel files named YEAR + team scores.

If possible, the folder should contain only the files you’re going to combine, as this makes the process cleaner and easier in later steps. However, if you must store other files in this folder as well, I’ll show you shortly how to ensure only the correct files are selected for the data merge.

Once the files are correctly organized into the folder according to the above prerequisites, you’re ready to start pulling the data together.

First, open a new Microsoft Excel workbook, start a blank worksheet, and press F12 to save the file in a different folder from where the individual files you’re going to combine are located.

Blank Workbook is selected in the Microsoft Excel welcome screen.

Related

The Best Excel Keyboard Shortcuts I Use as a Power User

The key to excelling in your spreadsheet work.

Next, in the Data tab on the ribbon, click “Get Data.” Then, hover over “From File,” and select “From Folder.”

From Folder is selected in the From File section of the Get Data drop-down menu in the Data tab of Excel's ribbon.

Now, in the Browse dialog box, locate and select the folder where the files you want to combine are stored, and click “Open.”

A folder named Team Scores in Windows 11 is selected in the Browse dialog box, and the Open button is highlighted.

Step 3: Choose the Files You Want to Combine

What you do in this step depends on what’s stored in the folder you selected. If it contains only the files you want to merge, see Section 3A below. On the other hand, if the folder also contains some files you don’t want to merge, skip to Section 3B.

3A: The Folder Contains Only the Files I Want to Merge

Earlier, I said that the workbook-merging process is cleaner and easier if the folder you select is dedicated to the files you want to combine. This is because you don’t need to filter out any unwanted files. So, since you’re already ready to combine the files, click “Combine,” and in the drop-down menu that appears, click “Combine And Transform Data.”

Three Excel files with similar names are listed in a dialog box in Excel, and Combine And Transform Data is selected in the Combine drop-down menu.

Now, after Excel briefly evaluates your data, you’ll see the Combine Files dialog box, and you’re ready to skip to Step 4.

The Evaluating Query window in Microsoft Excel.

3B: The Folder Contains Some Files I Don’t Want to Merge

If the selected folder also contains files other than the ones you want to merge, after you locate the folder in Step 2, you’ll see them listed in the details. In this case, you need to click “Transform Data,” as you want to make changes to the file selection before you combine the data.

An extraneous file is included in a list of files in a dialog box in Excel, and Transform Data is selected.

Clicking this option launches the Power Query Editor, a separate window within Microsoft Excel where you can filter out the files you don’t want to include in the combining process.

Excel's Power Query Editor, with four file names—one extraneous—listed in the query.

In this case, the file named Contact Details needs to be excluded, so click the filter drop-down arrow in the Name column header, uncheck that file, and click “OK.”

The file named Contact Details is unchecked in the Name column of Excel's Power Query Editor.

Now, only the files you want to combine are listed, so go ahead and click the double down arrow in the Content column to launch the Combine Files dialog box.

The double down arrow in the header of the Content column in Excel's Power Query Editor.

Step 4: Combine the Files

There are a few things to look out for in the Combine Files dialog box.

First, by default, the workbook nominated as the sample file is the first one you selected in the list. The sample file will dictate how the data is structured when the files are combined, so, as long as all your files are structured consistently, it’s fine to leave this option as is.

The Sample File area of the Combine Files dialog box in Excel, with First File selected in the drop-down menu.

Second, if your workbooks have more than one worksheet tab, you’ll see them listed in the Display Options pane on the left. This is why it’s important that all the tabs you want to combine across the nominated workbooks have the same name. Also, if you have formatted the data as Excel tables and named them, you’ll see the list of names here.

The Display Options pane in the Combine Files dialog box in Microsoft Excel.

In this example, however, each workbook only has one worksheet (named Scores), so go ahead and select this option. After reviewing the preview of the selected sample file in the right-hand pane, click “OK” to confirm and launch the Power Query Editor.

The Scores worksheet tab in Excel's dialog box is selected, a preview of the sample file is viewable in the right-hand pane, and the OK button is highlighted.

Step 5: Transform the Data

If this is the first time you’ve opened the Power Query Editor in Excel, it can initially be overwhelming. However, once you take some time to understand what the different areas of the editor do, you’ll realize that it’s actually an intuitive tool.

Related

How to Clean Up and Import Data Using Power Query in Excel

Don’t overlook this amazing Excel tool!

The left-hand pane is where all the queries are located. When combining data from various Excel workbooks, you only need to focus on two of these—the Transform Sample File query, which is used as a template for any changes you want to make to the datasets, and the appended query at the bottom of the list, which consolidates the files. However, depending on what you want to do, they’re both useful for transforming your data.

Two queries are highlighted in the Queries pane of Excel's Power Query Editor.

First, in the Transform Sample File query, click the number format icons in the header of each column to tell Excel what types of data they contain. In this example, the first, third, and fourth columns contain whole numbers, and the second column contains a date.

The number formats of various columns in Excel's Power Query Editor are adjusted to match their respective data types.

Look in the Query Settings pane on the right-hand side of the Power Query Editor to see (and remove if necessary) each step you take in transforming your data.

Next, in the appended query, we don’t need the Source Name column, but it would be handy to have the year for each team score.

The Source.Name column in Excel's Power Query Editor.

You can transform this column to keep only the years while removing the rest of the file names. To do this, click the column header so that all values in the column are selected, and in the Transform tab on the ribbon, click “Extract,” then “Text Before Delimiter.”

A column is selected in Excel's Power Query Editor, and Text Before Delimiter is selected in the Extract drop-down menu.

In this case, we want to keep the year, and remove everything after the first space. So, in the Delimiter text field, type a single space. Then, click “Advanced Options,” and select “From The Start Of The Input.” Now, click “OK.”

A space delimiter is added to the Text Before Delimiter dialog box in Excel's Power Query Editor, and From The Start Of The Input is selected in Advanced Options.

Finally, double-click the column header to rename it Year, and change the data type to “Whole Number.”

A column in Power Query Editor is renamed Year, with the data type changed to Whole Number.

Take a moment to scroll down the combined data list to check that there aren’t any errors or any further transformations you wish to make.

Related

4 Excel Power Query Commands You Need to Know

Become an expert data manipulator.

Step 6: Load the Combined Data Onto a New Worksheet

Now that the data from the workbooks has been combined and transformed, it’s time to see how it looks in a regular Excel worksheet. In the Home tab on the Power Query Editor window, click the top half of the “Close And Load” split button.

The top half of the Close And Load split button in Power Query Editor is selected.

Click the bottom half of the “Close And Load” split button for more loading options. For example, you can load the data onto an existing worksheet or as a PivotTable.

Now, the data loads on a new worksheet as a formatted Excel table, meaning you can format its appearance and properties in the Table Design tab on the ribbon.

The Table Design tab on the Microsoft Excel ribbon is activated.

Related

Everything You Need to Know About Excel Tables (And Why You Should Always Use Them)

This could totally change how you work in Excel.

To make further changes to the query in the Power Query Editor, after activating the Queries And Connections pane in the Data tab, right-click the query, and select “Edit.”

The Queries And Connections Pane in Microsoft Excel is activated, and the right-click menu on the primary query is expanded, where Edit is selected.

Once you’ve made the necessary edits in the Power Query Editor, click “Close And Load” again to update the resultant dataset.

Step 7: Append More Data From Additional Workbooks

Finally, let’s imagine the data for 2024 has now come in, and you want to append this new information to the existing query. Amazingly, because you’ve already taken the necessary steps in the Power Query Editor, all you need to do is ensure the workbook meets all the criteria I outlined in Step 1, and click a single button in Excel to refresh the table.

First, move the workbook containing the data to the folder where the previous years’ data is located, ensuring that the workbook name, worksheet structure, and tab name are consistent with the other files.

A Windows 11 folder containing four Excel workbooks, each named YEAR + Team Scores.

Then, open the workbook containing the previously appended data, and in the Queries And Connections pane (which you can activate by clicking “Queries And Connections” in the Data tab on the ribbon), click the “Refresh” icon next to the primary query.

The refresh icon next to a query in Excel's Queries And Connections pane is selected.

After giving Excel a few seconds to complete this update, scroll down to see the additional data appended to the bottom of the table.

New data is appended to the bottom of a table in Excel through Power Query.

To keep any formatting you applied to the table before refreshing the Power Query, click “Properties” in the Table Design tab on the ribbon, and ensure “Preserve Cell Formatting” is checked. If you change the column widths, and don’t want these to automatically fit to the data they contain each time you refresh, uncheck “Adjust Column Width.”


As well as appending data from separate workbooks saved into a folder, you can stack data from multiple Excel sheets within a single workbook by creating data connections between them and combining the queries. What’s more, you can use Power Query Editor to import tables from the web.

أضف تعليق