Hello everybody!
I am using the following code to copy the same sheet from several workbooks into a new workbook.
Sub CopySameSheetFrmWbs()
Dim wbOpen As Workbook
Dim wbNew As Workbook
'Change Path
Const strPath As String = "E:\Proforma Term 1 2017\"
Dim strExtension As String
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
On Error Resume Next
ChDir strPath
'Change extension
strExtension = Dir("*.xlsm")
Set wbNew = Workbooks.Add
'Change Path, Name and File Format
wbNew.SaveAs Filename:="E:\Proforma Term 1 2017\AllProformaC", FileFormat:=xlWorkbookNormal
Do While strExtension <> ""
Set wbOpen = Workbooks.Open(strPath & strExtension)
With wbOpen
.Sheets("ProformaC Term 1").Copy After:=wbNew.Sheets(wbNew.Sheets.Count)
wbNew.Sheets(wbNew.Sheets.Count).Name = wbNew.Sheets(wbNew.Sheets.Count).Cells(5, 4)
.Close SaveChanges:=False
End With
strExtension = Dir
Loop
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
On Error GoTo 0
End Sub
However, the only thing it's doing is create the file AllProformaC. That's all. It's not copying the sheets at all.
Any help please?
Thank you.
Same post here.
https://www.mrexcel.com/forum/excel-...ml#post4803354
http://www.ozgrid.com/forum/showthre...633#post790633
Bookmarks