'Bouton Valider, enregistre les infos du formulaire dans feuille "Enrg Mouvts"
Private Sub CommandButton1_Click()
Dim num As Long 'N° de la ligne
Dim i, J As Integer
Dim Lg
'Si les parties avec le repère * n'est pas renseigné alors message d'alerte
If ComboBox1 = "" Or ComboBox2 = "" Or ComboBox3 = "" Or ComboBox4 = "" Or TbHeureDeb = "" Or TbHeureFin = "" Then
MsgBox "Le repère * indique renseignement obligatoire.", vbOKOnly + vbInformation, "Information"
Exit Sub
End If
'Si tout est renseigné, un message de confirmation s'affiche
If MsgBox("Confirmez-vous cet enregistrement ?", vbYesNo, "Demande de confirmation") = vbNo Then
Exit Sub
Else
With Sheets("Enrg Mouvts")
num = Sheets("Enrg Mouvts").Range("A65536").End(xlUp).Row + 1
For Lg = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(Lg) = True Then
.Range("A" & num).Value = TextBox1
.Range("B" & num).Value = TextBox2
.Range("C" & num).Value = ComboBox1
.Range("D" & num).Value = ComboBox2
.Range("E" & num).Value = ComboBox3
.Range("F" & num).Value = Format(Me.TbHeureDeb.Value, "hh:mm") 'TbHeureDeb
.Range("G" & num).Value = Format(Me.TbHeureFin.Value, "hh:mm") 'TbHeureFin
.Range("I" & num).Value = ComboBox4
.Range("J" & num).Value = ListBox1.List(Lg) 'ListBox1
.Range("K" & num).Value = TextBox8
num = num + 1
End If
Next
If MsgBox("Voulez-vous faire un autre mouvement ?", vbYesNo) = vbYes Then
TextBox2 = Time
Unload Me
UF_Formation.Show
Else
Unload Me
End If
End With
End If
End Sub