Copy and paste entire rows

Nelson78

Well-known Member
Joined
Sep 11, 2017
Messages
526
Office Version
  1. 2007
Hello everybody.

I need to copy and paste all the rows from sheet Two to sheet One (beginning from the first empty row).
At the moment, the copy and paste works for only one row.

Where is the mistake?

Thank's.

Code:
Sub transfer()

Dim lr As Long, lr2 As Long, r As Long

lr = Sheets("Two").Cells(Rows.Count, "A").End(xlUp).Row
lr2 = Sheets("One").Cells(Rows.Count, "A").End(xlUp).Row

For r = lr To 2 Step -1

Rows(r).Copy Destination:=Sheets("One").Range("A" & lr2 + 1)

Next r

End Sub
 
Last edited:

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Ok try changing the line:

Code:
If .SpecialCells(xlCellTypeVisible).Count > 2 Then

to

Code:
If .SpecialCells(xlCellTypeVisible).Rows.Count > 1 Then
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,209
Members
453,022
Latest member
RobertV1609

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