Unprotecting worksheets with a macro

K

Katrina

I have a workbook with multiple worksheets. Each sheet is
password protected. I need to be able to unprotect these
sheet with the click of a button. Is there a way to put
the password into the code so that it doesn't prompt every
time.


As a follow up question, do you know how I can accomplish
this for multiple files at the same time.

Thanks for your help,
Katrina
 
C

Charles

You use the worksheet protect and unprotect:
you can attache this to a command button.

Worksheets("sheet1").Protect "david"
Worksheets("sheet1").Unprotect "david"


Hth

Charle
 
J

JE McGimpsey

One way:

This will unprotect all the sheets in all open workbooks.

Public Sub MultipleUnProtect()
Const PWORD As String = "drowssap"
Dim wbBook As Workbook
Dim wsSheet As Worksheet
On Error Resume Next
For Each wbBook in Workbooks
For Each wsSheet in wbBook.Worksheets
wsSheet.Unprotect PWORD
Next wsSheet
Next wbBook
End Sub
 
Top