resize for copy

Danny54

Active Member
Joined
Jul 3, 2019
Messages
295
Office Version
  1. 365
Platform
  1. Windows
how do i adjust the following code to change the copy and paste from Range("A" & i) to ("E" & i ).

i get a object doesnt support the property when i change A to E.

I tried to do offset(0, 4) and get a "You cannot past this here because the Copy area and paste area are not the same size.

Thanks

Dim j As Long
For j = 4 To lastrow
If Cells(j, 10).Value <> " " Then
i = i + 1
Rows(j).Copy Destination:=ThisWorkbook.Worksheets("Sheet1").Range("A" & i)
End If
Next
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
If you copy an entire row, then you have to copy it to col A, otherwise it's trying to put some of the cells off the edge of the sheet.

What range do you need to copy?
 
Upvote 0
It's because you are trying to copy the whole row. Change the Rows(j) to the range you want to copy.
 
Upvote 0
In that case try
Code:
Range("A" & j).Resize(, 10).Copy ThisWorkbook.Worksheets("Sheet1").Range("E" & i)
 
Upvote 0
perfect and I learnt something too. It didn't even enter my brain that a copy took the whole row and when i was trying to paste it i would push it off the end. (to the right)

Thanks so much.
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,121
Members
453,021
Latest member
Justyna P

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