Sheet Protection Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following code in my workbook. It allow the user to utilize the
outline and grouping, but it will not allow them to add and delete rows.

Private Sub Workbook_Open()
With Worksheets("vendorcommodities_detail")
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, _
Scenarios:=True, AllowInsertingColumns:=True, _
AllowInsertingRows:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True
.Protect Password:="add", userinterfaceonly:=True
.EnableOutlining = True
End With
End Sub

Since I am new to VBA, I am having trouble locating why it wont work.

Thanks
DIane
 
Try it this way:

Private Sub Workbook_Open()
With Worksheets("vendorcommodities_detail")
.EnableOutlining = True
.Protect DrawingObjects:=True, Contents:=True, _
Scenarios:=True, AllowInsertingColumns:=True, _
AllowInsertingRows:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, Password:="add", _
userinterfaceonly:=True
End With
End Sub
 
Perfect! Thank you

Tom Ogilvy said:
Try it this way:

Private Sub Workbook_Open()
With Worksheets("vendorcommodities_detail")
.EnableOutlining = True
.Protect DrawingObjects:=True, Contents:=True, _
Scenarios:=True, AllowInsertingColumns:=True, _
AllowInsertingRows:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, Password:="add", _
userinterfaceonly:=True
End With
End Sub
 
Back
Top