View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
confused guy and desperately in need ! confused guy and desperately in need ! is offline
external usenet poster
 
Posts: 12
Default lucking a cell automatically ...

Thanks again so much dear Mike

Best wishes,
M.M

"Mike H" wrote:

Hi,

Slightly more involved but try this. Select the cells you want this to work
for which in the case of my example are A1 - A10 and then
Format|cells|protection
remove the locked checkmark
Then
Tools Protection and protect the sheet with "mypass" as a passowrd (change
to suit but it must match the password in the code).

Right click the sheet tab, view code and paste this in and the first time
you enter xxx in a1 to A1 - A10 those cells also become protected.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
Application.EnableEvents = False
If Target.Value = "xxx" Then
ActiveSheet.Unprotect Password:="mypass"
Target.Locked = True
ActiveSheet.Protect Password:="mypass"
End If
Application.EnableEvents = True
End If

End Sub

Mike

"confused guy and desperately in need !" wrote:

Hi again

dose any one know how is possible to luck the cell automatically and
conditionally? i mean not by using the normal cell fomat option but forcing
the cell to be lucked when certain conditions meet?

any suggestion at all ?
Tks so much
M.M