bamaisgreat
Well-known Member
- Joined
- Jan 23, 2012
- Messages
- 831
- Office Version
- 365
- Platform
- Windows
As im sure you can tell in the code below that when I select cell E1 in sheet 2 it calls to run a macro to toggle protect and unprotect of sheet 2. I was wandering if there could be something added to the LockUnlock() code so cell E1 would actually show the text "PROTECTED" OR UNPROTECTED" depending on the worksheets status.
VBA Code:
Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Address = "$E$1" Then
Call LockUnlock
End If
End Sub
Code:
Sub LockUnlock()
If ActiveSheet.ProtectContents = True Then
ActiveSheet.Unprotect ""
Else
ActiveSheet.Protect ""
End If
End Sub