danbates77
Board Regular
- Joined
- Jan 10, 2017
- Messages
- 52
- Office Version
- 2016
Hi,
Please can someone help me?
I am trying to copy some data from one workbook to this one and if this code is triggered without anything being copied first, I get the following error
Runtime error 1004 - PasteSpecial method of range class failed
This is my code:
and this is the offending line
Is there a way to stop the error happening if the code is triggered without any data being copied first?
Any help would be appreciated.
Thanks
Dan
Please can someone help me?
I am trying to copy some data from one workbook to this one and if this code is triggered without anything being copied first, I get the following error
Runtime error 1004 - PasteSpecial method of range class failed
This is my code:
VBA Code:
Sub Macro1()
Dim lrcd As Long
Application.EnableEvents = False
Application.ScreenUpdating = False
lrcd = Sheets("Auto_Changeover").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Auto_Changeover").Cells(lrcd + 1, "A").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
and this is the offending line
VBA Code:
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Is there a way to stop the error happening if the code is triggered without any data being copied first?
Any help would be appreciated.
Thanks
Dan