Good morning guys,
Code:
Set mybook = Workbooks.Open("C:\Normal Files\Engineer Spreadsheet.xlsx")
Workbooks("Engineer Spreadsheet.xlsx").Activate
If ActiveSheet.Name = Format(Date - 2, "dd-mmm-yyyy") Then
ThisWorkbook.Sheets("ABC").Copy after:=mybook.Sheets(Format(Date - 2, "DD-MMM-YYYY"))
Else
ThisWorkbook.Worksheets("ABC").Copy after:=mybook.Worksheets(Format(Date - 1, "DD-MMM-YYYY"))
End If
ActiveSheet.Name = Format(Date, "DD-MMM-YYYY")
This automation error occurs at line ThisWorkbook.Worksheets("ABC").Copy after:=mybook.Worksheets(Format(Date - 1, "DD-MMM-YYYY"))
I have tried several ways it works fine but sometimes it throws error at this line.Any help is much appreciated.
Code:
Set mybook = Workbooks.Open("C:\Normal Files\Engineer Spreadsheet.xlsx")
Workbooks("Engineer Spreadsheet.xlsx").Activate
If ActiveSheet.Name = Format(Date - 2, "dd-mmm-yyyy") Then
ThisWorkbook.Sheets("ABC").Copy after:=mybook.Sheets(Format(Date - 2, "DD-MMM-YYYY"))
Else
ThisWorkbook.Worksheets("ABC").Copy after:=mybook.Worksheets(Format(Date - 1, "DD-MMM-YYYY"))
End If
ActiveSheet.Name = Format(Date, "DD-MMM-YYYY")
This automation error occurs at line ThisWorkbook.Worksheets("ABC").Copy after:=mybook.Worksheets(Format(Date - 1, "DD-MMM-YYYY"))
I have tried several ways it works fine but sometimes it throws error at this line.Any help is much appreciated.