copying parts of range from one worksheet to another

shantanu

New Member
Joined
Jul 30, 2010
Messages
22
I am trying to copy the range specified in parts to different positions on another worksheet but simply get the run time error 1004.
It says Range of Object_Worksheet failed.
I do not understand why it is failing.

Please help


Code:
Dim coprng As Range
Dim onrng As Range
Dim rawsheet As Worksheet
Dim tsheet As Worksheet
Dim j As Long
Dim i As Long
 
For j = 0 To 2
For i = 0 To 5
Set coprng = rawsheet.Range(Cells(182 + (80 * i) + (10 * j), 1), Cells(182 + 9 + 80 * i + 10 * j, 1))
Set onrng = tsheet.Range(Cells(68 + 35 * i, 7 + 14 * j), Cells(68 + 35 * i + 9, 7 + 14 * j))
coprng.Copy onrng

Next i
Next j
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I'd guess that your copy and paste ranges are different sizes. When pasting, you don't have to specify the whole range, just the top left corner.

Simplify onrng to just one cell and see if that works. For an easy test, just set it equal to sheet1.Range("A1") and see what happens.
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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