Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 03-26-2017, 04:30 PM
Logit Logit is offline How can I automatically protect only certain cells in Excel 2010 Windows 10 How can I automatically protect only certain cells in Excel 2010 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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How Do You Drag & Drop Cells in Excel 2010? juliansdad Excel 4 12-05-2013 01:15 AM
Linking cells on Excel 2010 teza2k06 Excel 1 02-05-2013 01:03 AM
How can I automatically protect only certain cells in Excel 2010 Excel VBA: Worksheet_Change Cells.Protect tinfanide Excel Programming 8 04-08-2012 09:58 PM
Protect / Lock Cells / Print Set-up? meggenm Excel 3 01-26-2012 09:57 PM
Automatically entering/fill data in cells in Excel 2003 dipdog Excel 0 08-17-2006 08:37 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:37 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft