ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unprotecting worksheets with a macro (https://www.excelbanter.com/excel-programming/303733-unprotecting-worksheets-macro.html)

Katrina

Unprotecting worksheets with a macro
 
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

Charles

Unprotecting worksheets with a macro
 
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

--
Message posted from http://www.ExcelForum.com


JE McGimpsey

Unprotecting worksheets with a macro
 
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


In article ,
"Katrina" wrote:

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.



All times are GMT +1. The time now is 10:10 AM.

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