Hi,
I have the below macro assigned to a button on my worksheet:
However, it should but doesn't allow the user to delete a row after it has inserted.
Suspecting a code error I recorded the following while selecting what the user can and can't do in the "Protect my sheet" dialog box to compare and tried it again:
Adding this second code to my original (top) macro still will not let the user delete the inserted row even though I've allowed it in the protection properties.
Can anyone point me to where I might be going wrong at all please?
Thank you for your time and any help.
I have the below macro assigned to a button on my worksheet:
Code:
Option Explicit
Sub Add_Prerequisite()
Dim rng As Range
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Sheets("Format Control").Range("B14").Value = _
Sheets("Cover Sheet").Range("B23").Value
With Sheets("Environment Information")
.Unprotect
Set rng = .Columns("A").Find(What:="2", After:=.Cells(1, 1), _
LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlPrevious, _
MatchCase:=False, SearchFormat:=False)
Sheets("Format Control").Rows(14).Copy
rng.Offset(1).EntireRow.Insert
rng.Offset(1, 2).Select
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, _
AllowInsertingRows:=True, AllowDeletingRows:=True
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
However, it should but doesn't allow the user to delete a row after it has inserted.
Suspecting a code error I recorded the following while selecting what the user can and can't do in the "Protect my sheet" dialog box to compare and tried it again:
Code:
Option Explicit
Sub Macro1()
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowInsertingRows:=True, AllowDeletingRows:=True
End Sub
Adding this second code to my original (top) macro still will not let the user delete the inserted row even though I've allowed it in the protection properties.
Can anyone point me to where I might be going wrong at all please?
Thank you for your time and any help.