ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   protecting sheets from a macro (https://www.excelbanter.com/excel-programming/288622-protecting-sheets-macro.html)

MattB[_2_]

protecting sheets from a macro
 
I am running a macro from an option button in a sheet
named "Summary". The macro make s various formatting
changes, but it needs to unprotect the sheet first. I am
running the following code, but the I get a run time error
when it executes. Can any one help?

Password = "Testpassword"
Worksheets("Summary").Select
Worksheets("Summary").Unprotect Password:=Password


He4Giv

protecting sheets from a macro
 
Here is a copy of a macro that I wrote...See if this helps
Sub unprotect_workbook_cc()
Dim password
password = InputBox("Please Enter Your Password!")
If password = "3579" Then
ActiveWorkbook.Unprotect password:="3579"
Sheets("chris").Visible = True
Else
MsgBox "Incorrect Password, Please Enter Again.",
vbExclamation
End If
End Sub
-----Original Message-----
I am running a macro from an option button in a sheet
named "Summary". The macro make s various formatting
changes, but it needs to unprotect the sheet first. I am
running the following code, but the I get a run time

error
when it executes. Can any one help?

Password = "Testpassword"
Worksheets("Summary").Select
Worksheets("Summary").Unprotect Password:=Password

.



All times are GMT +1. The time now is 02:06 PM.

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