Sheet Protection Macro

D

diaare

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
 
T

Tom Ogilvy

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
 
D

diaare

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top