Si cela peux vous aider voici les 2 codes qui fonctionnent séparément pour bloquer les cellules après modification et avoir une sélection multiple sur une liste déroulante.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
If Intersect(Target, Range("test1")) Is Nothing Then Exit Sub
Me.Unprotect 1234
For Each cell In Target
If Not cell.MergeCells Then
cell.Locked = True
Else
cell.MergeArea.Locked = True ' Verrouille la zone de cellules fusionnées
End If
Next cell
Me.Protect 1234
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim oldValue As String
Dim newValue As String
Application.EnableEvents = True
On Error GoTo Exitsub
If Not Intersect(Target, Range("E10,E12,E14,E16,E18,E20,E22,E24,E26,C10,C12,C14,C16,C18,C20,C22,C24,C26,B10,B12,B14,B16,B18,B20,B22,B24,B26,M10,M12,M14,M16,M18,M20,M22,M24,M26,N10,N12,N14,N16,N18,N20,N22,N24,N26,P10,P12,P14,P16,P18,P20,P22,P24,P26")) Is Nothing Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
GoTo Exitsub
Else: If Target.Value = "" Then GoTo Exitsub Else
Application.EnableEvents = False
newValue = Target.Value
Application.Undo
oldValue = Target.Value
If oldValue = "" Then
Target.Value = newValue
Else
If InStr(1, oldValue, newValue & ", ") > 0 Then
Target.Value = Replace(oldValue, newValue & ", ", "")
ElseIf InStr(1, oldValue, ", " & newValue) > 0 Then
Target.Value = Replace(oldValue, ", " & newValue, "")
ElseIf InStr(1, oldValue, newValue) = 0 Then
Target.Value = oldValue & ", " & newValue
End If
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub