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
 

Some videos you may like

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

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.
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,909
Messages
5,514,113
Members
408,983
Latest member
mlee13

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top