Hi all,
My macro uses the following code, but as it turns out for some reason I get (random) error messages. I can't determine the action that causes this so any thoughts would be appreciated.
This macro is triggered by clicking the copy image.
The macro then determines the row that the image is linked to, inserts a row below it, and copies the contents down.
The code is as follows.
Sub AddRow()
With ActiveSheet
.Unprotect
With Intersect(.Shapes(Application.Caller).TopLeftCell.EntireRow, .UsedRange)
.Copy
.Offset(1).Insert Shift:=xlDown
End With
Application.CutCopyMode = False
.protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End With
End Sub
ERROR MESSAGE that I receive from time to time...
Run-time error '-21474178-48 (80010108)':
Method 'Insert' of object "Range' failed
Not sure if this is relevant but the code to delete a row is as follows. This is triggered by clicking the trash can image:
Sub DeleteRow()
With ActiveSheet
.Unprotect
.Shapes(Application.Caller).TopLeftCell.EntireRow.Delete
.protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End With
End Sub
My macro uses the following code, but as it turns out for some reason I get (random) error messages. I can't determine the action that causes this so any thoughts would be appreciated.
This macro is triggered by clicking the copy image.
The macro then determines the row that the image is linked to, inserts a row below it, and copies the contents down.
The code is as follows.
Sub AddRow()
With ActiveSheet
.Unprotect
With Intersect(.Shapes(Application.Caller).TopLeftCell.EntireRow, .UsedRange)
.Copy
.Offset(1).Insert Shift:=xlDown
End With
Application.CutCopyMode = False
.protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End With
End Sub
ERROR MESSAGE that I receive from time to time...
Run-time error '-21474178-48 (80010108)':
Method 'Insert' of object "Range' failed
Not sure if this is relevant but the code to delete a row is as follows. This is triggered by clicking the trash can image:
Sub DeleteRow()
With ActiveSheet
.Unprotect
.Shapes(Application.Caller).TopLeftCell.EntireRow.Delete
.protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End With
End Sub