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

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

ChrisM

Well-known Member
Joined
Jun 11, 2002
Messages
2,129
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,693
Messages
5,833,142
Members
430,196
Latest member
rez5656

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
Top