Issue
I have a certain VBA code that I use for group/ungroup on protected sheet. It works just fine but only on one sheet. How can I modify it to work on two?
Private Sub Workbook_open()
With Sheet1
.Protect Password:="secret", userinterfaceonly:=True
.EnableOutlining = True
End With
End Sub
I don't know how to add more than one sheet. Can somebody help me?
Solution
Try this:
Private Sub Workbook_open()
With sheets("Sheet1 name")
.Protect Password:="secret", userinterfaceonly:=True
.EnableOutlining = True
End With
With sheets("Sheet2 name")
.Protect Password:="secret", userinterfaceonly:=True
.EnableOutlining = True
End With
End Sub
Note
Thanks to
Excelguru for this tip on the forum.