How to copy range values to next available free row using VB

D_Spark

Board Regular
Joined
Feb 4, 2007
Messages
232
Can anyone please assist?

Im wanting to create a VB button command so that when I click the CommandButton it will copy a range on a worksheet and pastespecial, values the cell values to the next free row

eg

Range to be copied ("C8:K8") on worksheet called "test"
Range ("C18:K18") on same worksheet have values already

so the VB will copy ("C8:K8") and then paste special values into ("C19:K19")

then if I were to run the command again it would copy ("C8:K8) into ("C20:K20")
this is because ("C18:K18") and ("C19:K19) are populated

etc
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Try

Code:
Sub Pspecial()
With Worksheets("test")
    .Range("C8:K8").Copy
    .Range("C" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,761
Members
452,940
Latest member
rootytrip

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