Justplainj
New Member
- Joined
- Apr 15, 2021
- Messages
- 47
- Office Version
- 365
- Platform
- Windows
Hi All.
I am using the following code to use a button to protect a sheet.
I am currently opting for the user to type the password in cell A2 to accept the password.
The unprotect macro is similar but I do not specify a range so that excel automatically uses a pop up where they enter the password.
Question.
How can I edit the above code to use a popup to enter the password when the sheet is being 'Protected', like it does when you unprotect?
Thanks in advance.
JPJ
I am using the following code to use a button to protect a sheet.
VBA Code:
Sub ProtectSheetWithPassword()
Dim sh As Worksheet
Set sh = ActiveSheet
sh.Shapes("ProtectBtn").Visible = msoFalse
sh.Shapes("UnprotectBtn").Visible = msoTrue
'Protect worksheet with a password
ActiveSheet.Protect Password:=Range("A2")
Range("A2").Select
Selection.ClearContents
End Sub
I am currently opting for the user to type the password in cell A2 to accept the password.
The unprotect macro is similar but I do not specify a range so that excel automatically uses a pop up where they enter the password.
Question.
How can I edit the above code to use a popup to enter the password when the sheet is being 'Protected', like it does when you unprotect?
Thanks in advance.
JPJ