Bonjour,
merci beaucoup pour votre aide
ce que je ne comprends pas, cest que me MsgBox se déclenche à partir d"une étape dans une macro mais qu'introduire dans la macro pour déclencher l'ouverture de l'userform ??
voila macro :
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim c As Range, v As Range
Dim Pers As String
Dim Jr As Integer
Dim N As Byte
With Sh
If Target.Column > 1 And Target.Column < 24 Then
For Each c In Target
Jr = c.Column
Pers = .Cells(c.Row, 1)
For Each v In .Range("A14:A15,A18:A20,A27:A28,A29:A30,A31:A32,A33:A34")
If v.Value = Pers Then
Application.EnableEvents = False
.Cells(v.Row, Jr) = c
Application.EnableEvents = True
End If
N = Verif(Jr)
If N > 0 And c <> "" Then
c.Value = ""
MsgBox "Permanence minimale atteinte"
End If
Next v
Next c
End If
End With
End Sub
Private Function Verif(ByVal Col As Integer) As Byte
Dim Nb(1 To 6) As Byte, j As Byte, Mx As Byte
Mx = 1
With ActiveSheet
For j = 2 To 6
Nb(j) = Application.CountA(Intersect(.Columns(Col), .Range("BLOC" & j)))
If j = 1 Then Mx = 2
If Nb(j) > Mx Then
Verif = j
Exit For
End If
Next j
End With
End Function