simora
09-02-2017, 08:12 PM
I'm trying to copy 2 sheets from the active workbook to a new workbook.
This code gives an error, ' Method Copy of object 'Sheets' failed '
but a new workbook "Book1" is created, but I can't see it or get to it.
ChDir "c:\Temp1"
b = MySht ' b is the sheet name of the current month
Sheets(Array("Sheet1", b)).Copy [ This code gives an error here | ' Method Copy of object 'Sheets' failed '
Set wb = ActiveWorkbook
With wb
.SaveAs fileName:="C:\Temp1\" & Sheets("Sheet1").Range("AX1").Text & " " & " The Closing Sheet" & ".xls"
.Close False
End With
I'm using office 2007. Is it true that you CANNOT copy a sheet with code inside of it ?
Even when I delete the worksheet code, it doesn't work.
The code previously worked when I only copied Sheet1
This code gives an error, ' Method Copy of object 'Sheets' failed '
but a new workbook "Book1" is created, but I can't see it or get to it.
ChDir "c:\Temp1"
b = MySht ' b is the sheet name of the current month
Sheets(Array("Sheet1", b)).Copy [ This code gives an error here | ' Method Copy of object 'Sheets' failed '
Set wb = ActiveWorkbook
With wb
.SaveAs fileName:="C:\Temp1\" & Sheets("Sheet1").Range("AX1").Text & " " & " The Closing Sheet" & ".xls"
.Close False
End With
I'm using office 2007. Is it true that you CANNOT copy a sheet with code inside of it ?
Even when I delete the worksheet code, it doesn't work.
The code previously worked when I only copied Sheet1