How to merge excel files into one workbook
Tutor 5 (58 Reviews)
Excel Tutor
Still stuck with a Excel question
Ask this expertAnswer
To merge Excel files into one workbook, use one of the following methods depending on how many files you have, whether you want to keep worksheet names, and whether you want an automatic repeatable process.
Method 1 — Manual: Open files and Move or Copy sheets (quick for a few files)
-
Open the destination workbook where you want all sheets combined.
-
Open a source workbook that contains sheets to move.
-
Right-click the sheet tab in the source workbook and choose Move or Copy….
-
In the dialog, set To book: to the destination workbook.
-
Choose where to place the sheet in Before sheet:.
-
Check Create a copy when you want to keep the sheet in the source file.
-
Press OK.
-
Repeat for each sheet or file.
Windows vs Mac differences
-
On Windows, the dialog label is Move or Copy… and looks the same across Excel versions.
-
On Mac, the dialog is identical in newer Excel for Mac builds; in very old Mac Excel versions, use the menu Edit → Move or Copy Sheet.
Method 2 — Power Query (recommended for many files, repeatable, safe)
To merge many files that share a similar structure (same columns), use Power Query's From Folder flow.
-
Place all source Excel files in a single folder.
-
In the destination workbook choose Data → Get Data → From File → From Folder.
-
Browse to the folder and click Open.
-
In the dialog click Combine → Combine & Transform Data.
-
In the Combine Files preview choose the worksheet or table to extract from each file.
-
Power Query Editor opens. Use steps to filter, rename, or remove columns.
-
Click Close & Load to load combined data into a sheet or data model.
Notes
-
Power Query treats each file as a data source. It is ideal when the files have identical column layout.
-
When new files are added to the folder, refresh the query to import them automatically.
-
On Mac, Power Query is available in recent Excel for Mac builds; some older Mac versions lack full Power Query support.
Method 3 — Copy/paste special (values only) (for combining data ranges)
-
Open source workbook and select the data range (no sheet-level merge).
-
Press Ctrl+C (Windows) or ⌘+C (Mac) to copy.
-
Switch to the destination workbook, select the top-left target cell.
-
Right-click and choose Paste Special → Values when you want only data and not formatting or formulas.
-
Repeat for each file.
Method 4 — VBA macro to combine sheets or worksheets from many files (repeatable, flexible)
To combine all worksheets from every workbook in a folder into the active workbook, run this macro.
-
Save and close other Excel workbooks you do not want processed.
-
Press Alt+F11 (Windows) or Fn+Option+F11 (Mac) to open VBA Editor.
-
Insert a new Module: Insert → Module.
-
Paste the code below into the module.
-
Save the destination workbook as a macro-enabled file (.xlsm).
-
Run the macro MergeAllWorkbooksInFolder.
Sub MergeAllWorkbooksInFolder()
Dim FolderPath As String
Dim Filename As String
Dim wbSource As Workbook
Dim ws As Worksheet
Application.ScreenUpdating = False
Application.EnableEvents = False
FolderPath = GetFolder()
If FolderPath = "" Then
MsgBox "No folder selected.", vbExclamation
GoTo Finish
End If
Filename = Dir(FolderPath & "*.xls*")
Do While Filename <> ""
On Error Resume Next
Set wbSource = Workbooks.Open(FolderPath & Filename, ReadOnly:=True)
If Err.Number <> 0 Then
Err.Clear
Filename = Dir()
GoTo ContinueLoop
End If
On Error GoTo 0
For Each ws In wbSource.Worksheets
ws.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count).Name = _
GetUniqueName(ThisWorkbook, ws.Name)
Next ws
wbSource.Close SaveChanges:=False
ContinueLoop:
Filename = Dir()
Loop
Finish:
Application.EnableEvents = True
Application.ScreenUpdating = True
MsgBox "Merge complete.", vbInformation
End Sub
Function GetFolder() As String
Dim fldr As FileDialog
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
.Title = "Select Folder with Excel files"
.AllowMultiSelect = False
If .Show = -1 Then
GetFolder = .SelectedItems(1) & Application.PathSeparator
Else
GetFolder = ""
End If
End With
Set fldr = Nothing
End Function
Function GetUniqueName(wb As Workbook, baseName As String) As String
Dim nameTry As String
Dim i As Long
nameTry = baseName
i = 1
On Error Resume Next
Do While Not wb.Sheets(nameTry) Is Nothing
Err.Clear
i = i + 1
nameTry = baseName & "_" & i
Loop
On Error GoTo 0
GetUniqueName = nameTry
End Function
VBA notes
-
The macro copies every worksheet into the destination workbook and renames duplicates by adding an index.
-
Save the destination workbook as
.xlsmto keep the macro. -
Mac Excel requires enabling macros in Preferences; folder picker code works in recent Mac builds.
Method 5 — Use Excel’s Get & Transform + Append Queries for multiple worksheets with different names
-
Use Data → Get Data → From File → From Workbook to pull one file.
-
In Power Query Editor, transform it into a standard table.
-
Choose Home → Append Queries → Append Queries as New.
-
Add the other queries (from other files or sheets).
-
Close & Load when complete.
When should you use each method?
-
Use Method 1 for a handful of sheets where manual control of placement and formatting is needed.
-
Use Method 2 for many files with a consistent structure and when you want a repeatable, refreshable process.
-
Use Method 3 to paste static values only.
-
Use Method 4 to automate merging many files or when worksheet structures vary, and you need sheet-level merges.
-
Use Method 5 when you must transform each source before combining.
Common pitfalls and how to avoid them
-
Duplicate sheet names cause errors. Resolve by renaming or using code that enforces unique names.
-
Hidden or protected sheets may not be copied. Unhide or unprotect before merging.
-
Different table/column structures break Power Query's combine. Standardize column headers or transform in the query.
-
External links remain when copying formulas. Use Paste Special → Values to remove links.
-
Very large files cause slow performance. Use Power Query and load into the data model to improve speed.
Quick checklist before merging (1–6)
-
Back up source files.
-
Place files to be merged in a single folder when using Power Query or VBA.
-
Decide whether you need formulas or values only.
-
Ensure worksheets are not protected or hidden.
-
Confirm the destination workbook has enough sheet name flexibility.
-
Save destination workbook as
.xlsxfor no macros,.xlsmif using VBA.
Troubleshooting questions — Question and answer
Will merging change the original files?
Yes. Moving sheets without checking Create a copy will remove the sheet from the source workbook. Use Create a copy to preserve originals.
Can I merge only certain sheets from many files?
Yes. Use Power Query and choose the target worksheet or table, or use a VBA filter to copy only sheets whose names match a pattern.
Do formulas keep working after merging?
Yes and no. Formulas will remain, but external workbook references will point to the original file unless you convert formulas to values or update references manually.
Short sample VBA to append used ranges as new sheets (alternate)
Sub AppendUsedRangesAsSheets()
Dim ws As Worksheet, newWs As Worksheet
For Each ws In ThisWorkbook.Worksheets
Set newWs = Worksheets.Add(After:=Worksheets(Worksheets.Count))
newWs.Name = "Copy_" & ws.Index
ws.UsedRange.Copy
newWs.Range("A1").PasteSpecial xlPasteValues
Next ws
Application.CutCopyMode = False
MsgBox "Copied used ranges as value-only sheets.", vbInformation
End Sub
-
Use Power Query for repeatable merges with consistent data layout.
-
Use the VBA approach for full workbook or sheet-level automation across many files.
-
Keep backups before any large merge operation.
-
Test the chosen method on a small sample of files before committing to the full set.
Get Online Tutoring or Questions answered by Experts.
You can post a question for a tutor or set up a tutoring session
Answers · 1
How to merge excel files into one file
Answers · 1
How to merge excel files into one
Answers · 1
How to mail merge from excel to email
Answers · 1
How to mail merge from excel to pdf
Answers · 1