Paste to end of table

spootage

New Member
Joined
Jul 17, 2017
Messages
9
Hello there!

I have recorded a macro via excel that will copy a string of data from one worksheet and paste to another worksheet of the same book.

At the moment it pastes my data to "A13" however this is a table and I would like it to paste to the end of said table, which will not always be "A13". My table is the only thing on the sheet and goes from A:G.

How can I modify my code below to achieve this?


Sub CopyPaste()

Sheets("Magic").Select
Range("J2:P2").Select
Selection.Copy
Sheets("Data").Select
Range("A13").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Coaching Form").Select

End Sub


Thanks in advance.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Try this:
VBA Code:
Sub Copy_Range()
'Modified 4/4/2022  9:57:41 PM  EDT
Application.ScreenUpdating = False
Dim Lastrow As Long
Lastrow = Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row + 1
Sheets("Magic").Range("J2:P2").Copy
Sheets("Data").Cells(Lastrow, 1).PasteSpecial
Application.CutCopyMode = False
Sheets("Coaching Form").Select
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution
Try this:
VBA Code:
Sub Copy_Range()
'Modified 4/4/2022  9:57:41 PM  EDT
Application.ScreenUpdating = False
Dim Lastrow As Long
Lastrow = Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row + 1
Sheets("Magic").Range("J2:P2").Copy
Sheets("Data").Cells(Lastrow, 1).PasteSpecial
Application.CutCopyMode = False
Sheets("Coaching Form").Select
Application.ScreenUpdating = True
End Sub

Thank you!

I had to modify your code slightly to paste as values only, so not including the formulas, but everything works now!
 
Upvote 0
Thank you!

I had to modify your code slightly to paste as values only, so not including the formulas, but everything works now!
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,580
Members
448,972
Latest member
Shantanu2024

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