VBA code working but giving "run-time error '-2147352571 (80020005)'"

ABech1

New Member
Joined
Oct 14, 2021
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hello

As so many others in here i'm a rookie at VBA trying to make some nice QOL improvements at my new job.

Hence i tried to add a button that would extend a small table (not formatted as table though) and keep the formatting and formulas. And I actually succeded (atleast a little bit) and the button works as intended. Therefore it was a surprise to me, that when i run the code in the VBA editor, it gives me "run-time error '-2147352571 (80020005)'"

As you can probably understand i do not like this, and would like to solve it before shipping the spreadsheet out to the intended users.

My code is as follows:

VBA Code:
Sub Tilføj_række_Hovedark()
    Dim b As Object, cs As Integer
    Set b = ActiveSheet.Shapes(Application.Caller)
    With b.TopLeftCell.EntireRow.Offset(-2, 0)
.Insert
.Cells(1, 2).Copy .Cells(0, 2)
.Cells(1, 3).Copy .Cells(0, 3)
.Cells(1, 4).Copy .Cells(0, 4)

    End With
End Sub

And the table looks like this. The object used as trigger is just an icon inserted from the excel-icons.


Debug.PNG


here's a pic of the debug result:

Debug2.PNG



I really can't seem to figure out, what the problem is.

Please help me :)

Thanks in advance
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,214,518
Messages
6,119,988
Members
448,935
Latest member
ijat

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