Sub Imprimer()
Dim F As Worksheet, datmin As Date, datmax As Date, lig As Byte, cel As Range
Set F = Sheets("Note de Frais - Historique")
Sheets("Note de Frais - Impression").Activate
If Not IsDate(Range("J5")) Then Range("J5").Select: MsgBox "Entrez une date...": Exit Sub
If Not IsDate(Range("J6")) Then Range("J6").Select: MsgBox "Entrez une date...": Exit Sub
datmin = Application.Min(Range("J5"), Range("J6"))
datmax = Application.Max(Range("J5"), Range("J6"))
lig = 11
Range("A12:I26") = ""
[COLOR="Red"]F.Range("A:J").Sort Key1:=F.Range("A1"), Order1:=xlAscending, Header:=xlYes ' tri[/COLOR]
For Each cel In Range(F.Range("A2"), F.Range("A65536").End(xlUp))
If cel >= datmin Then
[COLOR="red"]If cel > datmax Then Exit For[/COLOR]
If lig = 26 Then MsgBox "La note de frais ne peut comporter plus de 15 lignes !", 48: Exit For
lig = lig + 1
Cells(lig, 1).Resize(, 9) = cel.Resize(, 9).FormulaR1C1
End If
Next
[COLOR="red"]If lig = 11 Then MsgBox "Aucune date trouvée pour cette période": Exit Sub[/COLOR]
ActiveSheet.PrintOut Copies:=1
End Sub