Copy/Paste Issue

Jnrrpg11

New Member
Joined
Jun 29, 2017
Messages
28
Hello folks,

Apologies if this is a obvious issue I'm a beginner at VBA.
I have 2 sheets (Data1 & Data2) with tables of information which will vary in size.
I'm trying to write macro that will find the table size on "Data1" and paste it into a new sheet "AllData"
After that it will find the table size on "Data2" and paste it after the "Data1" info on the sheets "AllData".

Ive played about with this code but continually get a Runtime:1004 at the line in red.


Sub copyandpaste()



Sheets("Data1").Cells.Copy Destination:=Sheets("AllData").Range("A1")


Sheets("Data2").Range("A1", Range("A1").End(xlDown)).Copy
Sheets("AllData").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues


End Sub


Any help would be greatly appreciated.

Kind Regards
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
You haven't fully qualified the ranges.
Try
Code:
With Sheets("Data2")
   .Range("A1", .Range("A1").End(xlDown)).Copy
End With
note the . in front of both Range objects.
Also this will only copy col A, rather than the complete data
 
Upvote 0

Forum statistics

Threads
1,215,660
Messages
6,126,082
Members
449,286
Latest member
Lantern

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