• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Combining different workbooks in a single workbook

moizs

New Member
Hello I have many workbooks and i want to combine it into a single workbook and each workbook in the combined workbook should be in a separate sheet plsss help
 
Hi Moizs,


with poor validation and check..

Test below one

[pre]
Code:
Sub CombDiffWorkbook()
pnos = ThisWorkbook.Sheets.Count
FileNames = Application.GetOpenFilename(Filefilter:="Excel File (*.xlsx), *.xlsx", MultiSelect:=True)
For Each file In FileNames
Workbooks.Open file
Set ACWB = ActiveWorkbook
ActiveWorkbook.Sheets.Copy after:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
ACWB.Close False
Next file
For i = 1 To Sheets(pnos).Index
Sheets(i).Select False
Next i
Application.DisplayAlerts = False
ActiveWindow.SelectedSheets.Delete
Sheets(1).Select
MsgBox "Combining different workbooks in a single workbook Completed"
End Sub
[/pre]
https://dl.dropboxusercontent.com/u/78831150/Excel/Combining%20different%20workbooks%20in%20a%20single%20workbook.xlsb


Regards,

Deb
 
Back
Top