How to combine multiple excel files in one workbook

Fanny18

New Member
Joined
Mar 7, 2022
Messages
34
Office Version
  1. 2013
Platform
  1. Windows
Hi, how to combine multiple excel files in one workbook?
I have 202 excel files, i need to combine it into 1 workbook.
For eg, each excel files have 12 worksheets (Jan'22, Feb'22,........), i just need to combine all excel files with "Feb'22" sheet into one workbook become 202 worksheets with "Feb'22".
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try this macro, changing the path string, containing the 202 workbooks, as needed. It should import every "Feb'22" sheet to the macro workbook to sheets named "Feb'22", "Feb'22 (2)", "Feb'22 (3)", etc.

VBA Code:
Public Sub Import_Sheet_From_Workbooks()

    Dim path As String, fileName As String
    Dim wb As Workbook
    
    path = "C:\path\to\workbooks\"  'CHANGE THIS
    
    If Right(path, 1) <> "\" Then path = path & "\"
    
    Application.ScreenUpdating = False
    
    fileName = Dir(path & "*.xls*")
    Do While fileName <> vbNullString
        Set wb = Workbooks.Open(path & fileName, True)
        wb.Worksheets("Feb'22").Copy After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
        wb.Close
        fileName = Dir
    Loop
    
    Application.ScreenUpdating = True
    
    MsgBox "Done"
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,854
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top