Basically i have password to protect selected sheets.
Then ask for password to protect entire sheet.
The problem is that the inputted password is lost when closed and reopen the workbook.
And i can't find the bug in this one. I think another eye would be very helpful. Thanks.
Option Explicit
Public pWord1 As String
Public pWord2 As String
Private Sub CommandButton3_Click()
Const PW As String = "scorpion"
ActiveSheet.Unprotect PW
pWord1 = InputBox("PLEASE TYPE PASSWORD TO PROTECT. SALAMAT")
ActiveSheet.Cells.Locked = True
Columns("AA").Hidden = True
Columns("AE").Hidden = True
ActiveSheet.Protect Password:=pWord1
CommandButton3.Enabled = False
CommandButton4.Enabled = True
End Sub
Private Sub CommandButton4_Click()
Const PW As String = "scorpion" 'hehehe secret ko ito
pWord2 = InputBox("PLEASE TYPE PASSWORD TO UN_PROTECT. ")
If pWord2 = pWord1 Then
ActiveSheet.Unprotect pWord1
ActiveSheet.Cells.Locked = False
Columns("AA").Hidden = False
Columns("AE").Hidden = False
ActiveSheet.Protect PW
CommandButton4.Enabled = False
CommandButton3.Enabled = True
Else
MsgBox "YOU HAVE TYPE A WRONG PASSWORD", vbInformation
End If
End Sub
Bookmarks