DragonWood
06-30-2017, 04:57 PM
Greetings,
I have this wonderful little code that I found on this site a couple years ago. It has worked wonderfully everytime.
However, now I need to make a small change to it and I'm not sure how to go about that.
I have a couple sheets in my project that were imported from another source and are already password protected. I need the below code to ignore those sheets when applying this password.
I'm pretty sure I could use an Array of some kind to simply list the sheets I want to skip when applying the password. However, every example I have been finding has been providing a way to list the pages I want to apply the password to. Since there are only a couple that don't need it, and several that do, with the potential to have more added as the project progresses; I would like to just skip the ones I don't want to apply the password to.
I would appreciate any assistance I can get with this.
Private Sub Workbook_Open()
'Sets the password for each Worksheet, but still allows the code to work.
Dim wkSheet As Worksheet
For Each wkSheet In Worksheets
wkSheet.Protect "Password", UserInterfaceOnly:=True
Next wkSheet
End Sub
Thanks.
I have this wonderful little code that I found on this site a couple years ago. It has worked wonderfully everytime.
However, now I need to make a small change to it and I'm not sure how to go about that.
I have a couple sheets in my project that were imported from another source and are already password protected. I need the below code to ignore those sheets when applying this password.
I'm pretty sure I could use an Array of some kind to simply list the sheets I want to skip when applying the password. However, every example I have been finding has been providing a way to list the pages I want to apply the password to. Since there are only a couple that don't need it, and several that do, with the potential to have more added as the project progresses; I would like to just skip the ones I don't want to apply the password to.
I would appreciate any assistance I can get with this.
Private Sub Workbook_Open()
'Sets the password for each Worksheet, but still allows the code to work.
Dim wkSheet As Worksheet
For Each wkSheet In Worksheets
wkSheet.Protect "Password", UserInterfaceOnly:=True
Next wkSheet
End Sub
Thanks.