anuragkin's blog
Protect / Unprotect Worksheet
Submitted by anuragkin on 5 July, 2013 - 09:43Hi,
Here is the three separate macros.
One that provides the status in A1,
One to lock but leave ranges unlocked and
An unlock
The password is set as PASSWORD by default, although to utilise the unlock password you will need to use an input box
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveSheet.ProtectContents = True Then
ActiveSheet.Unprotect "PASSWORD"
Range("A1").Value = "PROTECTED"
ActiveSheet.Protect "PASSWORD"
Else
Range("A1").Value = "NOT PROTECTED"
End If
End Sub
Sub LockSheetCells()
Recent comments
5 years 44 weeks ago
6 years 30 weeks ago
6 years 42 weeks ago
6 years 45 weeks ago
6 years 46 weeks ago
6 years 51 weeks ago
7 years 7 weeks ago
7 years 8 weeks ago
7 years 8 weeks ago
7 years 8 weeks ago