copy method of range class failed. WHY??

Esviel

New Member
Joined
Jul 27, 2011
Messages
2
All I want to do is copy two columns from one workbook to another. Here's the line that's giving me trouble:


Code:
Workbooks(File_String).Worksheets("current_product_mgr_res_nophone").Columns("A:B").Copy Workbooks("Resume_Test_Final_Revisedv3.xlsm").Worksheets("Prod_Mgr_Res_NoPhone").Cells(4, col)

It says "copy method of range class failed". why can't I copy/paste??
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
You are copying .Columns("A:B") and trying to paste the two whole columns starting at row 4 .Cells(4, col)

The last 4 rows of the two columns would run off the sheet. That's causing the error.

Maybe try something like this.
Code:
Workbooks(File_String).Worksheets("current_product_mgr_res_nophone").[COLOR="Red"]Range("A1:B" & Rows.Count - 4)[/COLOR].Copy Workbooks("Resume_Test_Final_Revisedv3.xlsm").Worksheets("Prod_Mgr_Res_NoPhone").Cells(4, col)
 
Upvote 0
thank you SOO MUCH. that is extremely helpful.

As you can probably tell, I am VERY new to vba programming so I'm just recently learning all of the ins and outs. After hours of google searching I learned about the currentregion method, which allowed me to select those two columns regardless of how many rows were populated (because I was copying from a bunch of different sheets each with different numbers of rows, which is why I initially just copied the whole column). I was suspicious that copying the entire columns was the problem and now you've confirmed that.
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,894
Members
452,948
Latest member
Dupuhini

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