VBA code to copy and paste

rspalding

Active Member
Joined
Sep 4, 2009
Messages
295
Office Version
  1. 365
Platform
  1. Windows
Hi,

I need to copy data copy from AD5:AJ6 to the last row in column X to Column R. I've looked at the boards but have not been able to se the help that I need.

Thanks for helping.

Robert
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
There is something confusing in your explanation.
You only want to copy this range: AD5:AJ6
And where do you want to paste it?
You can give an example of where you want to paste it.
That is, if the last row with data in column R is 23, then do you want to paste in cell X23?

Try:

VBA Code:
Sub copyandpaste()
  Dim lr As Long
  lr = Range("R" & Rows.Count).End(3).Row   'last row in column X
  Range("AD5:AJ6").Copy Range("X" & lr)
End Sub
 
Upvote 0
Hi,

would this do what you need ?

VBA Code:
Sub move_data()

lastrow = ActiveSheet.Cells(Rows.Count, "R").End(xlUp).Row
newrow = lastrow + 1
ActiveSheet.Range("AD5:AJ6").Copy Range(Cells(newrow, 18), Cells(newrow + 1, 24))

End Sub
 
Upvote 0
Hi,

would this do what you need ?

VBA Code:
Sub move_data()

lastrow = ActiveSheet.Cells(Rows.Count, "R").End(xlUp).Row
newrow = lastrow + 1
ActiveSheet.Range("AD5:AJ6").Copy Range(Cells(newrow, 18), Cells(newrow + 1, 24))

End Sub
Yes this worked by changing ActiveSheet.Cells(Rows.Count, "R" to ActiveSheet.Cells(Rows.Count, "X"

Thanks
 
Upvote 0

Forum statistics

Threads
1,221,537
Messages
6,160,403
Members
451,644
Latest member
hglymph

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