password protect multiple worksheets with macro and exceptions

D

Danodob

I have a 50+ sheet workbook that I need to password protect with a macro.
Unfortunately, I need to have exceptions for hyperlinks along with autosort
and autofilter among others. I have found answers for autofilter on this
site but no luck with the others. I am using the following code to protect:

Private Sub CommandButton1_Click()

Dim wSheet As Worksheet

For Each wSheet In Worksheets

If wSheet.ProtectContents = True Then

wSheet.UnProtect Password:=TextBox1.Text

Else

wSheet.Protect Password:=TextBox1.Text

End If

Next wSheet

Unload Me

End Sub


Any help would be greatly appreciated.

Thank you in Advance,

Dan
 
Top