Private Sub CommandButton2_Click()
Dim Tablo, k As Long, Lign As Long, Present As Boolean
If ComboBox1.ListIndex = -1 Then
MsgBox "Sélectionner un CODE", vbInformation, "Erreur :"
Exit Sub
End If
Present = False
With Sheets("Actions a entreprendre")
Tablo = .Range("A8:A" & .Range("A65536").End(xlUp).Row)
For k = LBound(Tablo) To UBound(Tablo)
If Tablo(k, 1) = Me.TextBox1 Then
Present = True
Lign = k + 7
Exit For
End If
Next
If Present Then
If .Cells(Lign, CDbl(Me.ComboBox1.List(Me.ComboBox1.ListIndex, 3))) = "X" Then
MsgBox "Action déjà réalisée !", vbInformation, "Attention :"
Exit Sub
Else
If MsgBox("Confirmer l'ajout !", vbInformation + vbYesNo, "Confiramtion") = vbYes Then
.Cells(Lign, CDbl(Me.ComboBox1.List(Me.ComboBox1.ListIndex, 3))) = "X"
Me.ComboBox1.ListIndex = -1
Me.TextBox2 = ""
Me.TextBox3 = ""
Call UserForm4.Maj_Usf4
End If
End If
Else
If MsgBox("Machine non reprise, confirmer l'ajout :", vbInformation + vbYesNo, "Ajout machine :") = vbYes Then
.Cells(.Range("A65536").End(xlUp).Row + 1, 1) = Me.TextBox1
.Cells(.Range("A65536").End(xlUp).Row, CDbl(Me.ComboBox1.List(Me.ComboBox1.ListIndex, 3))) = "X"
Me.ComboBox1.ListIndex = -1
Me.TextBox2 = ""
Me.TextBox3 = ""
Call UserForm4.Maj_Usf4
End If
End If
End With
End Sub