[COLOR="DarkSlateGray"][B]Private Sub CommandButton1_Click()
Dim lig&, i As Date, dd(), oDat&()
On Error GoTo ErrDate
If CDate(UserForm1.TextBox2.Value) - CDate(UserForm1.TextBox1.Value) > 30 Then
MsgBox "il y a plus de 31 jours entre la 1ére et la 2ème date."
Else
If UserForm1.OptionButton1.Value = True Then dd = Array(2, 4, 6) Else dd = Array(1, 3, 5)
For i = CDate(UserForm1.TextBox1.Value) To CDate(UserForm1.TextBox2.Value)
If (Weekday(i) = dd(0)) + (Weekday(i) = dd(1)) + (Weekday(i) = dd(2)) Then
lig = lig + 1
ReDim Preserve oDat(1 To 1, 1 To lig)
oDat(1, lig) = i
End If
Next
With Range("A5") [COLOR="SeaGreen"]'Première cellule recevant une date.[/COLOR]
.Value = " "
.Resize(Cells(Rows.Count, 1).End(xlUp).Row - .Row + 1, 1).ClearContents
If lig Then .Resize(lig, 1).Value = WorksheetFunction.Transpose(oDat)
End With
MsgBox lig
UserForm1.Hide
End If
Exit Sub
ErrDate:
MsgBox "Une erreur est apparue dans la saisie des dates."
End Sub[/B][/COLOR]