ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Code Issue (https://www.excelbanter.com/excel-programming/429246-macro-code-issue.html)

uncbluegal

Macro Code Issue
 
I've entered the following code within my excel document:

Sub UnlockAllSheets()
Const thePassword = "filepassword"
Dim anySheet As Worksheet
For Each anySheet In ThisWorkbook.Worksheets
anySheet.Unprotect Password:=thePassword
Next
End Sub

Sub LockAllSheets()
Const thePassword = "filepassword"
Dim anySheet As Worksheet
For Each anySheet In ThisWorkbook.Worksheets
anySheet.Protect Password:=thePassword
Next

End Sub


I have many locked and unlocked cells within this 13 worsheet workbook. I
can easily run either the unlock or lock macro - but - I'm never asked for
the password when I run either macro. Why is this?


Gord Dibben

Macro Code Issue
 
The password is provided in the macros so won't get asked for it.


Gord Dibben MS Excel MVP

On Mon, 1 Jun 2009 13:31:01 -0700, uncbluegal
wrote:

I've entered the following code within my excel document:

Sub UnlockAllSheets()
Const thePassword = "filepassword"
Dim anySheet As Worksheet
For Each anySheet In ThisWorkbook.Worksheets
anySheet.Unprotect Password:=thePassword
Next
End Sub

Sub LockAllSheets()
Const thePassword = "filepassword"
Dim anySheet As Worksheet
For Each anySheet In ThisWorkbook.Worksheets
anySheet.Protect Password:=thePassword
Next

End Sub


I have many locked and unlocked cells within this 13 worsheet workbook. I
can easily run either the unlock or lock macro - but - I'm never asked for
the password when I run either macro. Why is this?



uncbluegal

Macro Code Issue
 
So how exactly then do I lock down and protect cells from being edited on
multiple spreadsheets?

"Gord Dibben" wrote:

The password is provided in the macros so won't get asked for it.


Gord Dibben MS Excel MVP

On Mon, 1 Jun 2009 13:31:01 -0700, uncbluegal
wrote:

I've entered the following code within my excel document:

Sub UnlockAllSheets()
Const thePassword = "filepassword"
Dim anySheet As Worksheet
For Each anySheet In ThisWorkbook.Worksheets
anySheet.Unprotect Password:=thePassword
Next
End Sub

Sub LockAllSheets()
Const thePassword = "filepassword"
Dim anySheet As Worksheet
For Each anySheet In ThisWorkbook.Worksheets
anySheet.Protect Password:=thePassword
Next

End Sub


I have many locked and unlocked cells within this 13 worsheet workbook. I
can easily run either the unlock or lock macro - but - I'm never asked for
the password when I run either macro. Why is this?





All times are GMT +1. The time now is 03:00 PM.

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