Hi
I have a macro that locks the cell (cell rangeis given) after entering data into cell & thereafter if we have tochange the value of cell it asks for password. It works well.
I want somechanges in this macro - currently if I move cursor on locked cell then alsoit prompt for password & i want if i edit that cell by double click or F2then only he ask for password.
Any help achieving this would be greatly appreciated...
Thanks in Advance !!!
I have a macro that locks the cell (cell rangeis given) after entering data into cell & thereafter if we have tochange the value of cell it asks for password. It works well.
I want somechanges in this macro - currently if I move cursor on locked cell then alsoit prompt for password & i want if i edit that cell by double click or F2then only he ask for password.
Any help achieving this would be greatly appreciated...
Thanks in Advance !!!
Code:
[COLOR=#333333]Private Sub Worksheet_Change(ByVal Target As Range)[/COLOR]
Dim changed As Range
Set changed = Intersect(Target, Range("AK4:AK240"))
If Not changed Is Nothing Then
If TargetLocked <> True Then
ActiveSheet.Unprotect ("123456789")
Target.Locked = True
ActiveSheet.Protect ("123456789")
Else
End If
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Pword As String
Dim changed As Range
Set changed = Intersect(Target, Range("AK4:AK240"))
If Not changed Is Nothing Then
If Target.Locked = True Then
Pword = InputBox("Enter Password", "Welcome"")
On Error GoTo Getout
ActiveSheet.Unprotect Pword
Target.Locked = False
ActiveSheet.Protect Pword
End If
End If
Exit Sub
Getout: MsgBox "Wrong Password", vbCritical, "Your Busted"
[COLOR=#333333]End Sub
[/COLOR]
Last edited: