1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
Private Sub Worksheet_Change(ByVal Target As Range)
Const nbcol As Long = 10
Dim col As Long
'activation protection générale
If Target = [A1] And [A1] = "" Then ActiveSheet.Unprotect
' protection des lignes
If Target.Column = 1 And Target.Row > 1 Then
ActiveSheet.Unprotect
If LCase(Target) = "x" Then
Target.Offset(0, 1).Resize(1, nbcol).Locked = True
Else
For col = 1 To nbcol
If Left(Target.Offset(0, col).Formula, 1) <> "=" Then Target.Offset(0, col).Locked = False
Next col
End If
End If
If [A1] = "x" Then ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub |
Partager