Copying 2 dynamic ranges together

CookieMonster76

Board Regular
Joined
Apr 30, 2015
Messages
200
Hi
I have this bit of code, but is there a way to combine it so it copies A1:C and P1:R at the same time - By doing it the way I am currently I am having difficulty in lining it up on the destination spreadsheet due to the fact that there are blanks in Col D in Sheet 3, so the previous last cells in Col A and Col D are not the same

Sheets("Sheet3").Select

With (Sheets ("Sheet2")
.Range("A1:C" & .Range("A" & .Rows.Count).End(xlUp).Row).Copy Destination:=Sheets("Sheet3").Range("A1048576").End(xlUp).Offset(1, 0)
.Range("P1:R" & .Range("A" & .Rows.Count).End(xlUp).Row).Copy
End with

Range("D1048576").End(xlUp).Offset(0, 1).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False

Thanks

Paul
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
If you want cols P:R copied as values try
Code:
Dim NxtRw As Long
Sheets("Sheet3").Select

With Sheets("Sheet2")
NxtRw = Sheets("Sheet3").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
.Range("A1:C" & .Range("A" & .Rows.Count).End(xlUp).Row).copy Destination:=Sheets("Sheet3").Range("A" & NxtRw)
.Range("P1:R" & .Range("A" & .Rows.Count).End(xlUp).Row).copy
End With

Range("D" & NxtRw).End(xlUp).Offset(0, 1).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
 
Upvote 0
Thanks for this

However, I get a 1004 run-time error at this point:

.Range("A1:C" & .Range("A" & .Rows.Count).End(xlUp).Row).copy Destination:=Sheets("Sheet3").Range("A" & NxtRw)
 
Upvote 0
Apologies it should be
Code:
NxtRw = Sheets("Sheet3").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)[COLOR=#ff0000].Row[/COLOR]
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,905
Messages
6,175,297
Members
452,633
Latest member
DougMo

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