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
 

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