Hi,
Help please to modify VBA code below in excel 2010 for step 1 only with Step 2 is working. see below. :
STEP 1
Blank work sheet. Click button from excel sheet (Open folder) and browse and select folder path you want and run the merge multisheets. ( Note I don't want manually add folder path in the VBA code, I want to browse and select folder only and under the folder see number of excel file ready to merge multisheets all in 1 file.
STEP 2
"Merge all sheets in 1 file" - Merge all worksheets from multiple workbooks (3 files containing various number of sheets and different name some might be 2 or 3 or 4 sheets each. Note if sheet name are same e.g. sheet1 and another file contain sheet1 and merge you see output sheet1, sheet1(2) not overwrite)
1 folder contains 3 excel workbook files.
Excel workbook file 1 contains 2 sheets ("A","B")
Excel workbook file 2 contains 3 sheets ("B","D","E")
Excel workbook file 3 contains 2 sheets ("G","J")
Output:
New Excel workbook called "Mergemultisheets" with 7 sheets ("A","B","B(2)","D","E","G","J")
Message box say "Merge all completed".
**************************
Here is the VBA code for step 2: Mergeallsheets
Option Explicit
Sub MergeMultiSheets()
Dim Path As String
Dim FileName As String
Dim Wkb As Workbook
Dim WS As Worksheet
Application.EnableEvents = False
Application.ScreenUpdating = False
Path = "C:\TESTFOLDER\" 'Change as needed
FileName = Dir(Path & "\*.xlsx", vbNormal)
Do Until FileName = ""
Set Wkb = Workbooks.Open(FileName:=Path & "\" & FileName)
For Each WS In Wkb.Worksheets
WS.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
Next WS
Wkb.Close False
FileName = Dir()
Loop
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.DisplayAlerts = False
Sheet1.Delete
Application.DisplayAlerts = True
End Sub
**************************
Thank you,
BW
Mr Singh