ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   password protect multiple worksheets with macro and exceptions (https://www.excelbanter.com/excel-programming/419014-password-protect-multiple-worksheets-macro-exceptions.html)

Danodob

password protect multiple worksheets with macro and exceptions
 
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


All times are GMT +1. The time now is 07:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com