Copying listrow throws an error (copy method of range class failed) why?

Lil2606

Board Regular
Joined
Jan 29, 2019
Messages
79
Hi all,

I have the following code:

Code:
[COLOR=#333333]If Not Intersect(Selection, ActiveSheet.ListObjects(1).DataBodyRange) Is Nothing Then[/COLOR]<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">
Dim CopyRownr As Long

CopyRownr = ActiveCell.Row - ActiveSheet.ListObjects(1).HeaderRowRange.Row


Dim CopyRow As Range

Set CopyRow = ActiveSheet.ListObjects(1).ListRows(CopyRownr).Range

CopyRow.Copy Destination:=ActiveSheet.ListObjects(2).ListRows.Add       'This is the highlighted line by the debugger
 </code>[COLOR=#333333]End if[/COLOR]

Which is supposed to copy the row (my active cell is in) from the first table to the second, exactly as it is. The second table is the exact copy of the first under a different name and it's databodyrange deleted. I do have formulas in the last 3 columns (sum formulas to sum a range from the same row like: "=SUM([@[a column]:[another column]])") I don't know if they are the trouble makers.. I just don't know why this won't work....

Please help!

Posted on ExcelForum as well. Link:
https://www.excelforum.com/excel-pr...od-of-range-class-failed-why.html#post5127244
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Solution:

Code:
[COLOR=#333333]If Not Intersect(Selection, ActiveSheet.ListObjects(1).DataBodyRange) Is Nothing Then[/COLOR]<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Dim CopyRownr As Long

CopyRownr = ActiveCell.Row - ActiveSheet.ListObjects(1).HeaderRowRange.Row


Dim CopyRow As Range

Set CopyRow = ActiveSheet.ListObjects(1).ListRows(CopyRownr).Range

CopyRow.Copy Destination:=ActiveSheet.ListObjects(2).ListRows.Add.Range       '.RANGE!!!!!!!!!</code><code style="color: rgb(51, 51, 51); font-size: 12px; font-style: inherit; font-weight: inherit; margin: 0px; padding: 0px; line-height: 12px;"> </code>[COLOR=#333333][COLOR=#333333]End if[/COLOR][/COLOR]
 
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,182
Members
448,948
Latest member
spamiki

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