Combining Multiple Excel Files Into One: Copy, Power Query, and What Breaks
Twelve monthly files into one annual register should take a minute. It takes an afternoon because one file has a header in row three and another has a total row at the bottom. Do it once, properly, and it stops being an afternoon.
Short answer
Which method, for which situation
| Situation | Method | Why |
|---|---|---|
| Three files, once | Copy and paste | Setting up a query takes longer than the task |
| Twelve files, every month | Power Query, From Folder | Set up once; each month is a refresh |
| Files from several people, layouts nearly but not exactly the same | Power Query, with the cleaning defined in the query | The differences become query steps rather than manual corrections |
| Hundreds of files | Power Query, From Folder | Manual methods are not viable at this volume |
| Files that change layout unpredictably | Neither — fix the source first | Any method you choose becomes maintenance you cannot control |
Method 1: copy and paste, done properly
For a small number of files this is genuinely the right answer. A few habits make it much less error-prone.
Add a source column first
Paste values, not formatting
Check the header of every file before pasting
Delete total rows as you go
Reconcile when you finish
The subtotal row is the classic silent failure
Method 2: Power Query, From Folder
This is the method worth building. The exact menu labels differ slightly between Excel versions, but the shape of the process is the same.
Put the files in a folder of their own
Start from the workbook you want the result in
Choose Combine, then select the sheet
Do the cleaning in the transform query, not in each file
Add the source file column
Load the result, then check the counts
Where the transformations actually live
When the files are not quite identical
| Difference | Where to handle it |
|---|---|
| A title row above the header in some files | Remove the top rows in the transform query, then promote headers — this works if the offset is the same in every file |
| A total row at the bottom | Filter it out in the transform query. If the total row is identifiable by a word in one column, filter on that word |
| An extra column in one file | Remove or keep the column explicitly in the transform query so every file ends with the same columns |
| A renamed sheet in one file | Standardise the name in the source files; selecting by position works until somebody inserts a sheet |
| Files in more than one folder | A second From Folder query per folder, then append the results |
| A file saved as .xls rather than .xlsx | Convert it once; older formats are handled less predictably |
Method 3: a VBA loop
A macro that opens each file in a folder and appends its rows is a common approach, and a reasonable one if you are already comfortable writing VBA. It is faster than manual pasting and slower than a query to set up.
- The folder path is hard-coded. Move the folder and the macro stops — if you are lucky.
- Sheet names are hard-coded. One file with a different sheet name breaks it or, worse, appends the wrong sheet.
- It does not verify what it did. A macro that appends and reports no error is not evidence that the rows are correct. There is no built-in check unless you write one.
- Application.ScreenUpdating and DisplayAlerts. Turning these off makes the macro faster and removes the visual clues when it goes wrong. If you do it, build in a log.
The general problem with recorded macros — that they contain positions rather than intentions — is covered in why Excel macros break.
Worked example: twelve monthly registers into one annual register
A business keeps each month's GST sales register in its own workbook, named for the month. Twelve files, all with the same columns, all with a total row at the bottom.
| Step | What happens | What it avoids |
|---|---|---|
| Point the query at the folder | Twelve files listed with their names and modification dates | Manually opening each file to check it is there |
| Promote headers in the transform query | One header row used for every file | The offset errors that come from pasting blocks of different shapes |
| Filter out the total rows | The row where the first column contains “Total” is removed | Twelve subtotal rows silently doubling every annual figure |
| Set column types explicitly | Date columns become dates, amount columns become numbers | Text-formatted amounts that will not sum |
| Add the source file name | Each row carries the month it came from | Having to search the files to trace a row |
| Check the counts | Sum of the twelve file row counts equals the combined row count | A combine that quietly dropped a file |
The five things that break a combine
- Extra rows above the header. A report title in row one shifts the entire file. The query reads the title as the header and the headers as data.
- Total rows below the data. Read as data, and included in every total you produce.
- Columns that exist in some files only. Power Query handles this more gracefully than copy and paste, but the resulting column will contain nulls that you need to handle explicitly.
- Duplicate file names or copies. A file named “August (2).xlsx” is read as a thirteenth month, and nothing flags it.
- Files that are not data. A template, an instructions file, a workbook that happens to be saved in the same folder. All are read. Keep the folder clean or filter the query by file name.
Verifying the result
| Check | How | What a failure means |
|---|---|---|
| Row count | Sum the row counts of the source files, compare with the combined table | A file was missed, or a total row was included, or rows were dropped |
| Control total | Sum a numeric column in each source file, compare with the sum in the combined table | Values were converted incorrectly, or rows are missing |
| Distinct source values | Count the distinct values in the source column | A file was read twice, or two files carry the same recorded source name |
| Spot check | Pick three rows from the combined table and find them in their source file | The columns are misaligned — the most serious failure, and the one the totals will not catch |
The spot check catches what the totals cannot
Common mistakes
- Combining before checking the files. Open two or three and look at the structure first. It is faster to fix six files than to debug a query that assumed all twelve were identical.
- Doing the cleaning after the combine. Where a defect belongs to a source file, clean it in the transform query so it stays fixed next month.
- Leaving the source column out. Then nothing in the output can be traced.
- Not checking the row count. A combine that loses a file looks entirely normal.
- Loading to a pivot table. Load the combined data to a table first, then pivot from it. Pivoting directly from a query gives you less room to check before you summarise.
- Assuming the folder is stable. Somebody will save a copy into it. Either filter the query by file name pattern, or accept that you have to check.
After the combine, the comparison
A combined register is usually the input to something else — a reconciliation against a system report, or a check against last year. That second step is a comparison, and it has the same requirements: a key column, rules stated explicitly, and a check that the counts tie.
The methods for that are in comparing two Excel files. If the comparison is the repetitive part and the combining is already solved, the Piloteq Automate workflow is where the matching rules live as a saved set rather than as formulas in the combined sheet.
If you would rather not build this by hand
Compare the combined file against the source
Once the files are combined, the next question is usually whether the combined register agrees with another set of records. Piloteq Automate applies that comparison on the key columns you choose and returns the missing and changed records with a reason.
- ✓Rules applied identically across the combined data
- ✓Missing records reported for each side
- ✓Duplicate detection across the whole set
- ✓Results as an exportable difference list
Frequently asked questions
What is the fastest way to combine multiple Excel files into one sheet?+
Power Query with a From Folder source. You point it at the folder, define the transformations once — promote the headers, set the column types, remove the total rows — and it reads every file in that folder into a single table. Files added to the folder later are picked up on Refresh, so the work is done once rather than repeated every period.
How do I combine files that have different sheet names?+
In Power Query, the combine step relies on the files having the same structure, so a sheet renamed in one file will not be found. The workable approaches are to standardise the sheet name across the files, or to change the navigation step so it selects a sheet by position rather than by name. Selecting by position works until somebody inserts a sheet ahead of it, so standardising the name is the more durable fix.
Why do I need a source column when combining files?+
Because without it, a row in the combined table has no record of where it came from. When a total does not agree, or a duplicate appears, the first question is always which file it was in — and if you did not keep that, you have to go back to the files and search. Add a column carrying the file name or the period before anything else.
Can I combine Excel files with a macro?+
Yes, and a recorded macro is a reasonable way to learn how. The limitation is that a macro contains hard-coded references — folder paths, sheet names, cell addresses — so it breaks when any of those change, and it often fails silently rather than stopping. Power Query does the same job and adapts to a changed number of files without any code.
What breaks a folder combine in Power Query?+
Five things, in order of frequency: a file with extra rows above the header, a total row at the bottom that is read as data, a column that exists in some files and not others, a sheet renamed in one file, and a file in the folder that is not part of the data — a template, a backup copy, or a file with a tilde in its name from being open elsewhere. Most of these can be handled in the query, but each one needs handling deliberately.
How do I check that combining the files did not lose anything?+
Compare the total row count and a control total. Count the rows per source file and add them up, then compare to the row count of the combined table. Do the same with a numeric column total. If both agree, the combine is arithmetically complete — which is a much stronger check than looking at the output and deciding it looks about right.