View Single Post
 
Old 03-26-2017, 04:30 PM
Logit Logit is offline Windows 10 Office 2007
Expert
 
Join Date: Jan 2017
Posts: 591
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

Paste this macro into the Sheet Level module:

Code:
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Value <> "" Then
        changeInput = MsgBox("Do you want to unlock the sheet?", vbYesNo + vbQuestion, "Unlock sheet")
        If changeInput = vbYes Then
            Dim pass As String
            pass = InputBox("Enter Password")
                If pass <> "password" Then
                    MsgBox ("Wrong password")
                Else
                    ActiveSheet.Unprotect Password:="password"
                    Target.Locked = False
                End If
        End If
    End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
   Dim cel As Range
    ActiveSheet.Unprotect Password:="password"
    For Each cel In Target
        If cel.Value <> "" Then
            cel.Locked = True
        End If
    Next cel
    ActiveSheet.Protect Password:="password"
End Sub
Attached Files
File Type: xlsm Cell Password Protect.xlsm (16.1 KB, 8 views)
Reply With Quote