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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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
Runtime error '9':

Subscript out of range




Have i got the code in the wrong place? Where should it be?
 
Upvote 0
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
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,214,587
Messages
6,120,405
Members
448,958
Latest member
Hat4Life

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