Hi I have the following:
Sub Procedure1()
'CopynPasteWrkBk:
Dim InputFile As Workbook
Dim OutputFile As Workbook
Dim Inputpath As String
Dim Outputpath As String '
'## Open both workbooks first:
Set InputFile = ActiveWorkbook
Set OutputFile = Workbooks.Open("M:\Bank\z" & InputFile.Sheets("Weeks").Range("I2").Value & " Bank.xlsm")
'Now, copy what you want from InputFile:
InputFile.Sheets("Hours").Range("A3:AL52").Copy
'Now, paste to OutputFile worksheet:
OutputFile.Sheets("Weekly Hours").Activate
OutputFile.Sheets("Weekly Hours").Range("B" & Rows.Count).End(xlUp).Offset(1).Select
ActiveSheet.Paste link:=True
'Close InputFile & OutputFile:
OutputFile.Close savechanges:=True
Application.CutCopyMode = False
Sheets("Rota").Select
Range("E33").Select
End Sub
Which works sometimes but then will come up with an error saying Microsoft Excel cannot paste the data error 1004. If I click debug then it highlights:
ActiveSheet.Paste link:=True
It's been fine for ages so don't know why I'm suddenly getting an error. If I click end then I can manually paste link with no issue.
Bookmarks