Copy method of Range class failed

mssbass

Active Member
Joined
Nov 14, 2002
Messages
253
Platform
  1. Windows
What am I doing wrong here?

Sub Appenddata()



Dim lastrow1 As Long, lastrow2 As Long
Dim ws1 As Worksheet, ws2 As Worksheet
Dim WB As Workbook


Set WB = ThisWorkbook
Set ws1 = WB.Sheets("ACT")
Set ws2 = WB.Sheets("OFC")


lastrow1 = ws1.Range("A" & Rows.Count).End(xlUp).Row
lastrow2 = ws2.Range("A" & Rows.Count).End(xlUp).Row + 1


ws2.Range("A2:D" & lastrow2).Copy ws1.Range("A" & lastrow1)
ws2.Range("E2:E" & lastrow2).Copy ws1.Range("F" & lastrow1)
ws2.Range("F2:F" & lastrow2).Copy ws1.Range("H" & lastrow1)
ws2.Range("G2:G" & lastrow2).Copy ws1.Range("J" & lastrow1)
ws2.Range("H2:H" & lastrow2).Copy ws1.Range("L" & lastrow1)
ws2.Range("I2:J" & lastrow2).Copy ws1.Range("N" & lastrow1)


End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
There's nothing wrong with the code that I can see.
Although I think the +1 should be on lastrow1 not lastrow2.

What error are you getting?
Do you have sheet protection on?
Do you have merged cells?
 
Upvote 0
Thank you - I don't have sheet protection on or merged cells. I'm simply trying to copy certain columns of data from 1 table on 1 worksheet to the bottom of another table on a different worksheet.

The code highlights this in yellow: ws2.Range("A2:D" & lastrow2).Copy ws1.Range("A" & lastrow1)

Error was: "Copy method of Range class failed" - Excel then locked up. Now, when I closed out and re-opened, it seems to run through the code.... I just upgraded to Excel 2016. I've noticed my Excel is 32 bit but my operating system is 64 bit. Could this have something to do with this issue?
 
Upvote 0
Glad it's sorted & thanks for the feedback.

I've noticed my Excel is 32 bit but my operating system is 64 bit. Could this have something to do with this issue?
No, this won't affect it.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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