Greetings
This code works great but can it be altered so that when the workbook is closed the Sheets are always protected.This way whenever the workbook is opened the sheets are in protected mode
Cheers
Code:Private Sub CommandButton1_Click() Dim strPassword As String Const strActualPassword As String = "ABCD" strPassword = InputBox("Please enter the password", "Protect/Unprotect Sheet") If strActualPassword = strPassword Then If Me.CommandButton1.Caption = "PROTECT SHEET" Then Me.CommandButton1.Caption = "UNPROTECT SHEET" UnlockCells Me.Protect Password:=strPassword Else Me.CommandButton1.Caption = "PROTECT SHEET" Me.Unprotect Password:=strPassword End If Else MsgBox "Invalid Password" End If End Sub Sub UnlockCells() Me.Range("B10:T10,B16:T18,B24:T28").Locked = False End Sub




Reply With Quote
Bookmarks