Hi,
I'm trying to get a macro to copy the last 30 rows of data to a different sheet.
I have the code below but I am getting "Run-time error 1004: Application-defined or Object-defined error"
I've tried a few different things but can't work out what's causing the error.
Any help would be really appreciated.
Thanks
I'm trying to get a macro to copy the last 30 rows of data to a different sheet.
I have the code below but I am getting "Run-time error 1004: Application-defined or Object-defined error"
I've tried a few different things but can't work out what's causing the error.
Code:
Sub Last30()
Dim lastrow As Long
With Sheets("Stage1")
lastrow = Sheets("Stage1").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("Stage1").Range("A" & lastrow - 29 & ":S" & lastrow).Copy Sheets("Stage1Last30").Range("A2")
End With
With Sheets("Stage2")
lastrow = Sheets("Stage2").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("Stage2").Range("A" & lastrow - 29 & ":AA" & lastrow).Copy Sheets("Stage2Last30").Range("A2")
End With
End Sub
Any help would be really appreciated.
Thanks
Last edited by a moderator: