Hi All,
I have a macro assigned to a button and when I execute the following code more than twice (this is the macro assigned to the button) I get the following error message:
Macro Code:
This used to work but can't quite figure out why it is displaying this error now.
Any help greatly appreciated.
Thanks.
I have a macro assigned to a button and when I execute the following code more than twice (this is the macro assigned to the button) I get the following error message:
Code:
Microsoft Visual Basic
Run-time error '-2147417848 (80010108/)':
Method 'Insert' of object 'Range' failed
Macro Code:
Code:
Option Explicit
Sub Add_Static_Environment_Server()
Dim rng As Range
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Sheets("Format Control").Range("C9").Value = _
Sheets("Cover Sheet").Range("B27").Value
Sheets("Format Control").Range("E9").Value = _
Sheets("Cover Sheet").Range("B23").Value
With Sheets("Environment Information")
.Unprotect
Set rng = .Columns("A").Find(What:="1", After:=.Cells(1, 1), _
LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlPrevious, _
MatchCase:=False, SearchFormat:=False)
Sheets("Format Control").Rows(9).Copy
rng.Offset(1).EntireRow.Insert
rng.Offset(1, 3).Select
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, _
AllowInsertingRows:=True, AllowDeletingRows:=True
End With
ActiveWindow.ScrollRow = 1
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
This used to work but can't quite figure out why it is displaying this error now.
Any help greatly appreciated.
Thanks.