Hoping someone is able to provide what I think is a simple solution I'm unable to find. I have a workbook with multiple sheets. Right now I currently password protect 10 of the sheets within the file. The issue I just ran into was someone change a sheet name and now the code won't work. I've not been able to find anything on line to show how to do what I'm currently doing but switch over to use the code name instead of the sheet name. Here is what my code currently looks like:
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets(Array("Totals", "Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item8", "Item9", "Item10"))
With ws
.Unprotect Password:="tunes"
.Protect Password:="tunes", userinterfaceonly:=True, AllowFormattingCells:=True, AllowFormattingRows:=True, AllowFormattingColumns:=True
.EnableOutlining = True
End With
Next ws
End Sub
Any thoughts on how to make this work using code name vs sheet name? I'm sure it's an easy fix, but still being a newbie to coding I'm at a loss.
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets(Array("Totals", "Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7", "Item8", "Item9", "Item10"))
With ws
.Unprotect Password:="tunes"
.Protect Password:="tunes", userinterfaceonly:=True, AllowFormattingCells:=True, AllowFormattingRows:=True, AllowFormattingColumns:=True
.EnableOutlining = True
End With
Next ws
End Sub
Any thoughts on how to make this work using code name vs sheet name? I'm sure it's an easy fix, but still being a newbie to coding I'm at a loss.