I have some VBA code that gives me "Runtime Error 1004: PasteSpecial method of Range class failed."
This is my code:
Sub CurrentToOld()
rownumber = ThisWorkbook.Sheets("As-Built Emergency").Range("A1", Worksheets("As-Built Emergency").Range("A2").End(xlDown)).Rows.Count
ThisWorkbook.Sheets("As-Built Emergency").Activate
ThisWorkbook.ActiveSheet.Rows("2:" & rownumber).Select
Selection.Cut
ThisWorkbook.Sheets("OLD AB EMERGENCY").Activate
ThisWorkbook.ActiveSheet.Range("A2").Select
ThisWorkbook.ActiveSheet.Range("A2").PasteSpecial Paste:=xlPasteSpecial, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End Sub
The error is in the 2nd to last line, and I can't seem to figure out why. I'm copying around 150 rows, and there are no merged cells within any of the copied ones.
I've tried removing the .Select statements and I change what I copied from Rows("2:" & rownumber) to Range("A1:D4") [something small which exists] but I still get the error.
EDIT: I put this line:
ThisWorkbook.ActiveSheet.Range("A2").Select
Because I wanted to test if it was a problem with the way I wrote the PasteSpecial code or if I actually needed to declare anything.
But the statement above works when I tested it in the debugger, so I'm at a standstill here.