VBA: Copying a range from one worksheet to another

MikeGar

New Member
Joined
Jun 22, 2018
Messages
1
Hi, I am trying to copy a range from one worksheet to another. Basically I have one long column of data (the data set repeats after 45 lines) and I want to copy it to multiple columns of 45 rows.
When I run the code I get run time error 1004: Method 'Range' of object'_Global' failed - the red line is where the error occurs

I think that this is the only relevant part of the code:

Dim Side1 As Integer
Dim Side2 As Integer
Dim col As Integer
Side1 = 45
col = 9


If NumParts <= 9 Then
For row = 1 To (NumParts * Side1) Step 45
Range(Worksheets(sheet1name).Cells(1, col), Worksheets(sheet1name).Cells(45, col)).Value = Range(Worksheets(sheet3name).Cells(row, 1), Worksheets(sheet1name).Cells((row + 44), 1)).Value


col = col + 1
Next


End If


Any advice would be great

Thanks,
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
It looks like you have a typo on the right hand side of the = You're looking at both sheet1 & sheet3
 
Upvote 0

Forum statistics

Threads
1,215,561
Messages
6,125,538
Members
449,236
Latest member
Afua

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