S
snsd
Hi:
I found the following macro on this site which allows you to place
password on every sheet in a workbook. It works great. The only thing
would like to add is a second prompt to confirm the password - the sam
way that you are prompted to verify the password when you select Tool
-> Protection -> Protect Worksheet. I don't want to accidentally appl
an incorrect password to all my sheets and then forget it! (Note:
obviously only want to have to confirm it once - and not for ever
sheet!)
Thanks in advance for your help.
Sub PasswordAppliedToAllSheets()
Dim myPwd As String
Dim wks As Worksheet
myPwd = InputBox(prompt:="Please enter the password to protect al
sheets.")
If Trim(myPwd) = "" Then
Exit Sub
End If
For Each wks In ThisWorkbook.Worksheets
If wks.ProtectContents _
Or wks.ProtectDrawingObjects _
Or wks.ProtectScenarios Then
'already protected
Else
wks.Protect Password:=myPwd
End If
Next wks
End Su
I found the following macro on this site which allows you to place
password on every sheet in a workbook. It works great. The only thing
would like to add is a second prompt to confirm the password - the sam
way that you are prompted to verify the password when you select Tool
-> Protection -> Protect Worksheet. I don't want to accidentally appl
an incorrect password to all my sheets and then forget it! (Note:
obviously only want to have to confirm it once - and not for ever
sheet!)
Thanks in advance for your help.
Sub PasswordAppliedToAllSheets()
Dim myPwd As String
Dim wks As Worksheet
myPwd = InputBox(prompt:="Please enter the password to protect al
sheets.")
If Trim(myPwd) = "" Then
Exit Sub
End If
For Each wks In ThisWorkbook.Worksheets
If wks.ProtectContents _
Or wks.ProtectDrawingObjects _
Or wks.ProtectScenarios Then
'already protected
Else
wks.Protect Password:=myPwd
End If
Next wks
End Su