I am trying to write a code to copy an unknown number of rows and paste it into a specific location in a separate worksheet. So far I have the code seen below.I Want to copy the data from columns A:F, for an unknown number of rows, and paste it starting in H6. I get an error in the code "Range("A1", lastrow).Select". The error is "Method range of object worksheet failed". All help is appreciated.
Dim lastrow As Long
Dim copyrange As Range
lastrow = Range("A65536").End(xlUp).Select
Range("A1", lastrow).Select
Selection.Copy
Sheets("Final").Select
Range("H6").Select
ActiveSheet.Paste
End Sub
If you were to debug this, you would dicsover that the value of
lastRow
is-1
. Get rid of the.Select
there (and everywhere, for that matter). You also have an error in your range.Copy
which I fix:Or, to just transfer the values, I think this will do it (untested):