Copy Destination with Variable Rows

PCWL

New Member
Joined
Jun 7, 2012
Messages
34
I am trying to use Copy Destination as opposed to using Copy then ActiveSheet.Paste, as it should help the program run faster.

I have looked online and every example of Copy Destination uses explicitly defined ranges (for example: Sheet1.Range("A1:A200").Copy Destination:=Sheet2.Range("B1")

However, I am trying to use user-defined rows instead. I have an integer variable "UserRow", and an integer variable "LastRow", which finds the last row of a certain range. I have tried modifying the Copy Destination in the example, but I end up getting Run-time error '1004': Application-defined or object-defined error.

I don't know if I should be using a different way to select the ranges or there is something wrong with my syntax?

Code:
    Dim LastRow As Integer
    LastRow = Range("CompletedJobNum").Rows(Range("CompletedJobNum").Rows.Count).Row
    Sheets("Current").Range(Cells(UserRow, 2), Cells(UserRow, 12)).Copy Destination:=Sheets("Current").Range(Cells(LastRow, 2))
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try

Code:
Dim LastRow As Long
    LastRow = Range("CompletedJobNum").Rows(Range("CompletedJobNum").Rows.Count).Row + 1
    Sheets("Current").Range(Sheets("Current").Cells(UserRow, 2), Sheets("Current").Cells(UserRow, 12)).Copy Destination:=Sheets("Current").Range("B" & LastRow)
 
Upvote 0
Try this.
Code:
Sheets("Current").Cells(UserRow, 2).Resize(,11).Copy Destination:=Sheets("Current").Cells(LastRow, 2)
[/code]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,206,817
Messages
6,075,041
Members
446,114
Latest member
FadDak

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top