0

I have created a simple macro to cut and paste data from one sheet to another and every once in a while I will get the Run time error 1004 cannot paste data error. It doesn't do it all the time.

Here is my current code:

Sub INSERTVE()
'
' INSERTVE Macro
'
' Keyboard Shortcut: Ctrl+Shift+I
'
 

     Application.Calculation = xlCalculationManual
        Application.ScreenUpdating = False
        Application.DisplayStatusBar = False
        ActiveSheet.DisplayPageBreaks = False
        Application.ScreenUpdating = False
        ActiveWorkbook.Names.Add Name:="newrowa", RefersToR1C1:=Rows(ActiveCell.Row)
        Application.Goto Reference:="newrowa"
        Application.Goto Reference:="NEWTRENDLOGITEM"
        Selection.Copy
        Application.Goto Reference:="newrowa"
        Selection.EntireRow.Insert
        Range("newrowa").Select
        ActiveCell.Rows("1:1").EntireRow.Select
        Application.Goto Reference:="insertsection"
        Selection.Copy
        Application.Goto Reference:="LASTROW"
        Selection.EntireRow.Insert
        ActiveWorkbook.Names.Add Name:="newrowZ", RefersToR1C1:=Rows(ActiveCell.Row)
        Range("newrowZ").Select
        ActiveWorkbook.Names("newrowZ").Delete
        ActiveCell.Rows("1:1").EntireRow.Select
        ActiveWorkbook.Names.Add Name:="newrowZ", RefersToR1C1:=Rows(ActiveCell.Row)
        ActiveCell.Rows("1:1").EntireRow.Select
        ActiveCell.Offset(0, 8).Range("A1").Select
        Sheets("ve-01").Select
        Application.Goto Reference:="newrowa"
        ActiveCell.Rows("1:1").EntireRow.Select
        ActiveCell.Offset(-1, 2).Range("A1").Select
        Selection.Copy
        Application.Goto Reference:="LASTROW"
        ActiveCell.Offset(-13, 2).Range("A1").Select
        **ActiveSheet.Paste link:=True**
        Application.Goto Reference:="newrowa"
        ActiveCell.Offset(-1, 3).Range("A1").Select
        Selection.Copy
        Application.Goto Reference:="LASTROW"
        ActiveCell.Offset(-13, 3).Range("A1").Select
        ActiveSheet.Paste link:=True
        Application.Goto Reference:="LASTROW"
        ActiveCell.Offset(-2, 16).Range("A1").Select
        Selection.Copy
        Application.Goto Reference:="newrowa"
        ActiveCell.Rows("1:1").EntireRow.Select
        ActiveCell.Offset(-1, 13).Range("A1").Select
        ActiveSheet.Paste link:=True
        Application.Goto Reference:="newrowa"
        ActiveCell.Rows("1:1").EntireRow.Select
        ActiveCell.Offset(-1, 1).Range("A1").Select
        Selection.Copy
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("VE-01").Select
        Range("newrowa").Select
        ActiveWorkbook.Names("newrowa").Delete
        ActiveWorkbook.Names("newrowz").Delete
        Application.CutCopyMode = False
        Application.ScreenUpdating = True
        Application.DisplayStatusBar = True
        ActiveSheet.DisplayPageBreaks = True
        Application.Calculation = xlCalculationAutomatic
    
End Sub

Any suggestions or ideas on why it only does this once in a while? Any tips for a newbie on how to correct this? The code errors out when it gets to ActiveSheet.Paste link:=True

Thanks,

Felix
  • 9
  • 3

0 Answers0