Private Sub Modifier_Click()
Dim ws As Worksheet
Dim ctrl As MSForms.Control
Dim ligne As Integer
Dim msg As Boolean

Set ws = Worksheets("Données brutes")

If MsgBox("Confirmez-vous la modification ?", vbYesNo, "Demande de confirmation") = vbYes Then

    If Me.ComboBox1.ListIndex = -1 Then Exit Sub
    
    ligne = Me.ComboBox1.ListIndex + 1

    If ComboBox1 = "" Or Date_modif = "jj/mm/aaaa" Or (DDL = False And Formulaire = False And Instruction = False And Liste = False And Modop = False And Plan = False And Procédure = False And Protocole = False) Then
        MsgBox ("Toutes les informations en gras ne sont pas remplies")
        Exit Sub
    End If
    
    'controle des dates dans usf
    For Each ctrl In Me.Controls
        If TypeName(ctrl) = "Textbox" Then
            Select Case ctrl.Name
                Case Is = "Date_modif"
                    If IsDate(ctrl) = False Then msg = True
                Case Is = "Appro_Prod"
                    If IsDate(ctrl) = True Then
                        If CDate(ctrl.Value) < CDate(Date_modif.Value) Then msg = True
                    End If
                Case Is = "Appro_aq"
                    If IsDate(ctrl) = True Then
                        If CDate(ctrl.Value) < CDate(Date_modif.Value) Then msg = True
                        If ctrl.Value < Appro_prod.Value And Appro_prod <> "jj/mm/aaaa" Then msg = True
                        If ctrl.Value < Priseco.Value And Priseco <> "jj/mm/aaaa" Then msg = True
                        If ctrl.Value < Datedif.Value And Datedif <> "jj/mm/aaaa" Then msg = True
                    End If
                    
                Case Is = "Priseco"
                    If IsDate(ctrl) = True Then
                        If CDate(ctrl.Value) < CDate(Date_modif.Value) Then msg = True
                        If ctrl.Value < Appro_prod.Value And Appro_prod <> "jj/mm/aaaa" Then msg = True
                        If ctrl.Value < Appro_aq.Value And Appro_aq <> "jj/mm/aaaa" Then msg = True
                        If ctrl.Value < Datedif.Value And Datedif <> "jj/mm/aaaa" Then msg = True
                    End If
                    
                Case Is = "Datedif"
                    If IsDate(ctrl) = True Then
                        If CDate(ctrl.Value) < CDate(Date_modif.Value) Then msg = True
                        If ctrl.Value < Appro_prod.Value And Appro_prod <> "jj/mm/aaaa" Then msg = True
                        If ctrl.Value < Appro_aq.Value And Appro_aq <> "jj/mm/aaaa" Then msg = True
                        If ctrl.Value < Priseco.Value And Priseco <> "jj/mm/aaaa" Then msg = True
                    End If
            End Select
            If msg = True Then Call Messagebox: msg = False: Exit Sub
        End If
    Next ctrl
    
    'Modification des données
    With Sheets("Données brutes").ListObjects(1).DataBodyRange
        .Item(ligne, 3) = Format(Date_modif, "dd/mm/yyyy")
    
        If Appro_prod <> "jj/mm/aaaa" Then .Item(ligne, 4) = Format(Appro_prod, "dd/mm/yyyy") Else .Item(ligne, 4) = vbNullString
        If Appro_aq <> "jj/mm/aaaa" Then .Item(ligne, 5) = Format(Appro_aq, "dd/mm/yyyy") Else .Item(ligne, 5) = vbNullString
        If Priseco <> "jj/mm/aaaa" Then .Item(ligne, 6) = Format(Priseco, "dd/mm/yyyy") Else .Item(ligne, 6) = vbNullString
        If Datedif <> "jj/mm/aaaa" Then .Item(ligne, 7) = Format(Datedif, "dd/mm/yyyy") Else .Item(ligne, 7) = vbNullString

        For Each ctrl In Me.Controls
            If TypeName(ctrl) = "OptionButton" Then
                If ctrl.Value = True Then .Item(ligne, 2) = ctrl.Caption: Exit For
            End If
        Next ctrl
    End With
End If
End Sub