Private Sub Worksheet_Activate()
Dim tablo, resu(), i&, mat$, txt$, n&, p%
With Feuil1.UsedRange 'CodeName de la feuille
tablo = .Resize(, 3) 'matrice, plus rapide
ReDim resu(1 To 2 * Application.Count(.Columns(1)), 1 To 3)
End With
For i = 1 To UBound(tablo)
If tablo(i, 1) Like "Matricule*" Then mat = tablo(i, 1)
If IsDate(tablo(i, 1)) Then txt = mat & Chr(1) & tablo(i, 1)
If IsNumeric(CStr(tablo(i, 3))) And mat <> "" Then
If tablo(i, 3) < TimeValue("08:00") Or tablo(i, 3) > TimeValue("19:00") Then
n = n + 1
p = InStr(txt, Chr(1))
resu(n, 1) = Left(txt, p - 1)
resu(n, 2) = CDate(Mid(txt, p + 1))
resu(n, 3) = tablo(i, 3)
End If
End If
Next
With [A3] 'à adapter
If n Then
.Resize(n, 3) = resu
.Resize(n, 3).Sort .Cells(1), xlAscending, .Cells(1, 2), , xlAscending, Header:=xlNo 'tri
.Resize(n, 3).Borders.Weight = xlThin 'bordures
End If
.Offset(n).Resize(Rows.Count - n - .Row + 1, 3).Delete xlUp 'RAZ en dessous
End With
End Sub