Private Sub CommandButton4_Click()
'il est tout à fait inutile de vider les TextBoxes !!!
Unload Me 'puisqu'on ferme l'UserForm
End Sub
Private Sub CommandButton5_Click()
Dim i As Byte, c As Object, a(1 To 10) As Date, P As Range, j As Byte
'---vérification des dates---
For i = 2 To 11
Set c = Controls("TextBox" & i)
If IsDate(c) Then
a(i - 1) = CDate(c)
c = Format(a(i - 1), "dd/mm/yyyy")
Else
MsgBox "Date non valide !", 48
c.SetFocus
c.SelStart = 0
c.SelLength = Len(c)
Exit Sub
End If
Next
'---entrées dans la feuille---
Set P = Sheets("Année").[B18:AK48]
P.Replace "Vac", "" 'RAZ
For i = 1 To 31
For j = 1 To 12
Set c = P(i, 3 * j - 2)
If c >= a(1) And c <= a(2) Or c >= a(3) And c <= a(4) Or c >= a(5) And c <= a(6) _
Or c >= a(7) And c <= a(8) Or c >= a(9) And c <= a(10) Then c(1, 3) = "Vac"
Next
Next
'---vidage des feuilles---
' UserForm2.Show 'UserForm2 me paraît bien inutile, une MsgBox suffit...
End Sub