Create command button to copy range and paste in another wrk sheet

jaxs2009

Board Regular
Joined
Nov 28, 2010
Messages
200
Excel 2007

Create a command button to copy data in a range then find the last row in another sheet and paste.

Sheet “PROJECT TRACKING” I placed a command button within “L6”cell. Each time the button is clicked, I would like the data copied from column “C” through Column “K” in row 6 and paste it in “CHANGE ORDER” sheet find last row and past, the paste range will be the same columns “C” through “K”

With each click I would like the data be transferred as described above.

In the “PROJECT TRACKING” sheet I would like to have this happen for each row 6 through 304 individually, do I need a command button in column “L” for each of the rows to transfer data from that row.

I have this VBA code now in this work book that works great, I referenced it along with the a excel book to help me write a VBA code as mentioned above but I get stuck.

Private Sub Worksheet_Change(ByVal Target As Range)

If Intersect(Target, Columns("AV")) Is Nothing Then Exit Sub

If Target.Value = vbNullString Then Exit Sub

Dim ws As Worksheet: Set ws = Sheets("PROJECT TRACKING")

If Target.Value = "AWARDED" Then

Range(Cells(Target.Row, "C"), Cells(Target.Row, "I")).Copy ws.Range("C" & Rows.Count).End(3)(2)

End If

End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
What about

Code:
Option Explicit

Sub Button1_Click()
Dim i As Integer, LastRow As Long


i = InputBox("Please enter the row number to copy", "Select Row", "6 - 304")


Sheets("PROJECT TRACKING").Range(Cells(i, 3), Cells(i, 11)).Copy


Sheets("CHANGE ORDER").Select


LastRow = Sheets("CHANGE ORDER").Cells(Rows.Count, "C").End(xlUp).Row


Cells(LastRow + 1, 3).Select
ActiveSheet.Paste


Application.CutCopyMode = False
End Sub
 
Upvote 0
Cooper645

It does not transfer code to "CHANGE ORDER" sheet

I start off by going to developer tab click on Insert click, then click on forms control button and then a "Assign Macro" window pops up, I clicked on new and the below VBA code is entered, I test and nothing. Below is what is in the VBA code now.

Sub Button333_Click()
End Sub
Sub Button1_Click()


Dim i As Integer, LastRow As Long


i = InputBox("Select Row", "6")


Sheets("PROJECT TRACKING").Range(Cells(i, 3), Cells(i, 11)).Copy


Sheets("CHANGE ORDERS").Select


LastRow = Sheets("CHANGE ORDER").Cells(Rows.Count, "C").End(xlUp).Row


Cells(LastRow + 1, 3).Select
ActiveSheet.Paste


Application.CutCopyMode = False


End Sub
 
Upvote 0
Cooper645

It does not transfer code to "CHANGE ORDER" sheet

I start off by going to developer tab click on Insert click, then click on forms control button and then a "Assign Macro" window pops up, I clicked on new and the below VBA code is entered, I test and nothing. Below is what is in the VBA code now.

Sub Button333_Click()
End Sub
Sub Button1_Click()



Dim i As Integer, LastRow As Long


i = InputBox("Select Row", "6")


Sheets("PROJECT TRACKING").Range(Cells(i, 3), Cells(i, 11)).Copy


Sheets("CHANGE ORDERS").Select


LastRow = Sheets("CHANGE ORDER").Cells(Rows.Count, "C").End(xlUp).Row


Cells(LastRow + 1, 3).Select
ActiveSheet.Paste


Application.CutCopyMode = False


End Sub

try deleting the text I highlighted in red.
 
Upvote 0
The blue text below is where the code error appears, the range in the row is good. I not recognizing what I am missing. Help would be greatly appreciated.


Sub Button16_Click()


Dim i As Integer, LastRow As Long


i = InputBox("Select Row", "6")


Sheets("PROJECT TRACKING").Range(Cells(i, 3), Cells(i, 11)).Copy


Sheets("CHANGE ORDERS").Select


LastRow = Sheets("CHANGE ORDER").Cells(Rows.Count, "C").End(xlUp).Row


Cells(LastRow + 1, 3).Select
ActiveSheet.Paste


Application.CutCopyMode = False


End Sub
 
Upvote 0
The break code, means you need to press the stop button in the VBA editor before trying to run it again. The macro stopped for an error and is now in break mode.
 
Upvote 0
Can I consider this issue now satisfactorily solved?
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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