1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
Private Sub CommandButton1_Click()
Dim derl%
Dim Continuer As Integer
derl = Worksheets("Data").Cells(Rows.Count, 1).End(xlUp).Row
If DTPicker1 <> "" And ComboBox4.Value <> "" And ComboBox5.Value <> "" Then
If Weekday(CDate(DTPicker1), 2) <> 7 And Weekday(CDate(DTPicker2), 2) <> 7 Then
If CDate(DTPicker1) > Now() Then
If DateDiff("d", Now(), CDate(DTPicker1)) > 10 Then
Jump: For Each cell1 In Worksheets("data").Range("C2:C" & derl)
If Cells(ActiveCell.Row, 3).Value > cell1.Value And cell1.Offset(0, 6).Value = "" And _
(cell1.Offset(0, 5).Value <> "" Or cell1.Offset(0, 6).Value <> "" Or cell1.Offset(0, 7).Value <> "") Then
MsgBox ("Vous n'avez pas convoqué pour des opérations précédentes ")
End If
Exit For
Next
Cells(ActiveCell.Row, 11) = CDate(DTPicker1)
Cells(ActiveCell.Row, 12) = CDate(Format(ComboBox4, "00") & ":" & Format(ComboBox5, "00"))
Cells(ActiveCell.Row, 13) = CDate(DTPicker2)
If Weekday(CDate(DTPicker2), 2) = 5 Then
Cells(ActiveCell.Row, 14) = "12:00"
Else
Cells(ActiveCell.Row, 14) = ""
End If
If DTPicker1 <> "" And Cells(ActiveCell.Row, 16).Value <> "Envoyé" Then
Cells(ActiveCell.Row, 16).Value = "Programmé"
End If
If Cells(ActiveCell.Row, 11).Value <> "" And DTPicker1 <> "" And Cells(ActiveCell.Row, 16).Value = "Envoyé" Then
Cells(ActiveCell.Row, 16).Value = "Reprogrammé"
End If
Unload Me
Else
Continuer = MsgBox("Date de convocation < 10j, valider la convocation?", vbYesNo + vbExclamation + vbDefaultButton2)
If Continuer = vbYes Then
GoTo Jump
End If
End If
Else
MsgBox ("Vous ne pouvez pas convoquer à une date inférieure à la date du jour")
End If
Else
MsgBox ("Vous ne pouvez pas convoquer un dimanche")
End If
Else
MsgBox ("Veuillez remplir les champs - Début -")
End If
End Sub |
Partager