0

I'm getting a Run-Time error '1004' "Paste method of Worksheet class failed" After the paste was completed. if I enter press Debug and move the pointer to the next line of the macro everything works fine,(until the loop comes back to the paste line" This is the code block:

    Set r1 = Range(Cells(2, col1), Cells(Range("C" & Rows.Count).End(xlUp).Row, col6))
    Set r2 = Range(Cells(2, col7), Cells(Range("C" & Rows.Count).End(xlUp).Row, col9))
    Union(r1, r2).Select
    Selection.Copy
    Sheets(Sheets.Count).Select
    Range("B" & lastrow + 1).Select
    ActiveSheet.Paste
    Application.CutCopyMode = False

After I've bypassed the line, to get past the error, for as many iterations as the loop requires, the macro completes, the sheet looks fine and contains no error.

If I manually perform the cut-and-paste, I get no errors.

I've run out of ideas. Any help would be appreciated

C0ppert0p
  • 634
  • 2
  • 7
  • 23
  • No errors here. As with all example code, it is best to provide all variable values so that others can reproduce your error. for instance is `col9` a variable in your code? Is is set somewhere? It might have something to do with another open object/workbook or something in the clipboard. – Rusan Kax Aug 30 '14 at 01:17
  • A good start would be to [avoid Select](http://stackoverflow.com/a/10717999/445425) – chris neilsen Aug 30 '14 at 02:33

0 Answers0