copy current row and paste to first empty row on sheet2

wisewood

Board Regular
Joined
Nov 7, 2002
Messages
193
Can someone please help me with a script that will detect the row that the current cell is in, select all cells in that row, copy them, and paste them into the first empty row on Sheet2.

A colleague of mine is wasting loads of time doing this manually over and over again.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Lewiy

Well-known Member
Joined
Jan 5, 2007
Messages
4,284
Give this a try:
Code:
Sub MyMacro()
Dim limit As Long
limit = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row + 1
Rows(ActiveCell.Row).Copy Destination:=Sheets("Sheet2").Rows(limit)
End Sub
 
Upvote 0

wisewood

Board Regular
Joined
Nov 7, 2002
Messages
193
Runtime error '9':

Subscript out of range




Have i got the code in the wrong place? Where should it be?
 
Upvote 0

Lewiy

Well-known Member
Joined
Jan 5, 2007
Messages
4,284
Is the worksheet you are copying to called “Sheet2”? If not then you will need to replace the word Sheet2 in the code with the name of your worksheet.
 
Upvote 0

wisewood

Board Regular
Joined
Nov 7, 2002
Messages
193
Thanks. I got there in the end.

Now I'm off to see if i can add in a few extra bits like highlighting the row background in grey... and maybe trigger it automatically.

Thanks.
 
Upvote 0

Forum statistics

Threads
1,191,683
Messages
5,987,991
Members
440,124
Latest member
dippy_egg

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
Top