Private Sub Worksheet_Change(ByVal Target As Range) colonne = Split(Target.Address, "$")(1) If colonne = "EP" Or colonne = "FM" Then valGY = Cells(Target.Row, "GY").Value Select Case valGY Case 0: Debug.Print "Ligne : " & Target.Row & " GY = 0" Range("DM" & Target.Row & ":DV" & Target.Row).Locked = False Case 1: Debug.Print "Ligne : " & Target.Row & " GY = 1" Range("DM" & Target.Row & ":DV" & Target.Row).Locked = True Case Else Debug.Print "Ligne : " & Target.Row & " GY = autre chose.." & valGY Range("DM" & Target.Row & ":DV" & Target.Row).Locked = False End Select End If End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub Worksheet_Change(ByVal Target As Range) colonne = Split(Target.Address, "$")(1) If colonne = "B" Or colonne = "FM" Then valGY = Cells(Target.Row, "GY").Value ActiveSheet.Unprotect "toto" Select Case valGY Case 0: Debug.Print "Ligne : " & Target.Row & " GY = 0" Range("DM" & Target.Row & ":DV" & Target.Row).Locked = False Case 1: Debug.Print "Ligne : " & Target.Row & " GY = 1" Range("DM" & Target.Row & ":DV" & Target.Row).Locked = True Case Else Debug.Print "Ligne : " & Target.Row & " GY = autre chose.." & valGY Range("DM" & Target.Row & ":DV" & Target.Row).Locked = False End Select End If ActiveSheet.Protect "toto", DrawingObjects:=True, Contents:=True, Scenarios:=True _ , AllowFormattingCells:=True, AllowFormattingColumns:=True, _ AllowFormattingRows:=True, AllowFiltering:=True End Sub
14 mai 2014 à 09:43