Combine Multiple workbookSheets into Master file Sheets

abhishekdevane

New Member
Joined
Feb 17, 2022
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
I am working on project where i need to add multiple workbooks Sheet in to master excel file.
For E.g
1.First Workbook name "Stats_CK"
2.Second Workbook name "Stats_AM".

Output Should be : Master Excel File with Sheets like Stats_CK and second Tab Stats_AM.
However i am getting an output reverse i.e. First tab Stats_AM and Stats_CK
I want macro should pick first workbook and paste in to Masterexcel first Tab


1645094442733.png


Code
Sub Conslidateworkbooks()
Dim FolderPath As String
Dim Filename As String
Dim Sheet As Worksheet
Application.ScreenUpdating = False
FolderPath = "H:\Desktop\Stats Report\"
Filename = Dir(FolderPath & "*.csv*")
Workbooks.Add
Set NewFile = ActiveWorkbook
MsgBox FolderPath
Dim i As Integer
i = 0
Do While Filename <> ""
Workbooks.Open Filename:=FolderPath & Filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=NewFile.Sheets(i + 1)
Next Sheet
Workbooks(Filename).Close
Filename = Dir()
i = i + 1
Loop
Application.ScreenUpdating = True
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
ActiveWorkbook.SaveAs Filename:="file"

End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

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