Macro for blocker from using cell range
With "qwerty" as defined name for range =Sheet1!$A$1:$F$12,Day!$A$26:$F$34
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myrange As Range
Set myrange = Me.Range("qwerty")
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, myrange) Is Nothing Then
With Me
.Protect Password:="justme"
.EnableSelection = xlNoRestrictions
End With
Else
If Intersect(Target, myrange) Is Nothing Then
Me.Unprotect Password:="justme"
End If
End If
ws_exit:
Application.EnableEvents = True
End Sub
Paste into Sheet1 code module.
Gord Dibben MS Excel MVP
On Tue, 23 Mar 2010 09:10:16 -0700, Lenny
wrote:
Is there a way to write code that can unlock a worksheet (w/password)
allowing the user access to functionality while relocking (w/password) the
worksheet should the user mouse click or move into a range of cells that
would normally be locked?
Assistance and a learning opportunity is always appreciated...
Regards, Lenny
|