Private Sub BtnValider_Click()
Dim X&, I&
Dim NbrRotation As Byte
 DateDebut = IIf(TxtDateRotation.Value = "", 0, TxtDateRotation.Value)
 datenaissance = IIf(TxtDateNaissance.Value = "", 0, TxtDateNaissance.Value)
 DatedebutFixe = IIf(TxtDateFixe.Value = "", 0, TxtDateFixe.Value)
 NbSemRot = IIf(CbNbSemRotation.Value = "", 0, CbNbSemRotation.Value)
    'If TxtDateRotation = "" And ObRotation = True Then MsgBox "Vous devez Sélectionner une date de début ": Exit Sub
    'If TxtDateNaissance = "" Then MsgBox "Vous devez Indiquer une date de Naissance ": Exit Sub
    'If TxtMdp = "" Then MsgBox "Vous devez Saisir un mot de passe (ATTENTION AUX MAJUSCULES) ": Exit Sub
    'If TxtDateFixe = "" And ObFixe = True Then MsgBox "Vous devez Sélectionner une date de début ": Exit Sub
    'If ChbMajoration = True And TxtTaux = "" Then MsgBox "Vous devez saisir un taux de Majoration": TxtTaux.SetFocus: Exit Sub
    'If ObFixe.Value = False And ObRotation.Value = False Then MsgBox "Vous devez choisir si le planning est fixe ou tournant": Exit Sub
    'If ObFixe.Value = True And CbSemTypeFixe = "" Then MsgBox "Vous avez choisi un Planning fixe, vous devez sélectionner la Semaine Type attribuée": CbSemTypeFixe.SetFocus: Exit Sub
    'If ObRotation.Value = True And CbNbSemRotation.Value = "" Then MsgBox "Vous avez choisi un Planning à rotation, vous devez sélectionner le nombre de semaines de rotation": CbNbSemRotation.SetFocus: Exit Sub
'    For I = 1 To NbrRotation
'        If Me.Controls("CbSemType" & I).Text = Empty Then MsgBox "Vous devez sélectionner " & NbrRotation & " Semaines type": Exit Sub
''    Next
' Modif pour tracer les variables à mettre dans la table TbId --------------------------------------------------------------
    A = Split("TxtInit,TxtMdp,ChbEffectif,ChbAbsence,ChbSemType,ChbAmplitude,ChbNbparTranche,ChbPosteService," & _
        "ChbCptHres,ChbPoste,ChbService,ChbJrOuv,ChbPlanning,ChbSoldeCompteurhr,ChbPersPres,ChbPrepaSalaire", ",")
    Dim Log
    If Not Dir(ThisWorkbook.Path & "\Journal.txt") = "" Then Kill ThisWorkbook.Path & "\Journal.txt"
    Set FSO = CreateObject("Scripting.FileSystemObject")
    For I = 0 To UBound(A)
        Set Log = FSO.OpenTextFile(ThisWorkbook.Path & "\Journal.txt", 8, True)
            Log.writeline Right(space(30) & [TbId].ListObject.ListColumns(I + 1), 30) & "=" & Me.Controls(A(I))
        Log.Close
    Next
' Fin de Modif --------------------------------------------------------------------------------------------------------------
    With Sheets("Id").Range("TbId").ListObject
            .ListRows.Add.Range.Value = Array(TxtInit, TxtMdp, Abs(ChbEffectif), Abs(ChbAbsence), Abs(ChbSemType), Abs(ChbAmplitude), Abs(ChbNbparTranche), Abs(ChbPosteService), _
             Abs(ChbCptHres), Abs(ChbPoste), Abs(ChbService), Abs(ChbJrOuv), Abs(ChbPlanning), Abs(ChbSoldeCompteurhr), Abs(ChbPersPres), Abs(ChbPrepaSalaire))
    End With
    With [TbEffectif].ListObject
            X = Application.IfError(Application.Match(TxtNom, .Range.Columns(1), 0), 0) And Application.IfError(Application.Match(TxtPrenom, .Range.Columns(2), 0), 0)
            If X <> 0 Then MsgBox "Ce Collaborateur existe déjà" & vbCrLf: Exit Sub ' Teste si n'existe pas déjà avec le nom et prénom
    End With
           
    With Range("TbEffectif").ListObject 'ajoute une ligne à TbEffectif
            .ListRows.Add.Range.Value = Array(TxtNom, TxtPrenom, CbPoste, CDate(datenaissance), CDbl(TxtNbHeure), ChbOui, TxtTaux, TxtInit, Abs(ObFixe), Abs(ObRotation), CDbl(NbSemRot), _
            CbSemTypeFixe, CbSemType1, CbSemType2, CbSemType3, CbSemType4, CbSemType5, CbSemType6, CDate(DateDebut), CDate(DatedebutFixe)) 'on ajoute une ligne au tableau
    End With
           
    If ObFixe = True Then
        ArchiverPlanningFixe
        xderligne
        Duplique_Planning
    ElseIf ObRotation = True Then
        ArchiverPlanningRotation
        xderligne
        Duplique_Planning
    End If
vidange
RemplitlesListes
End Sub