Unprotecting worksheets with a macro

  • Thread starter Thread starter Katrina
  • Start date Start date
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
 
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
 
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
 

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

Back
Top