Private Sub Worksheet_Activate()
Dim tabloRes(), tabloBis
tabloF = Array("Site 1", "Site 2", "Site 3") 'tableau des feuilles à traiter
dtPivot = DateSerial(Year(Date), Month(Date) - 3, Day(Date)) 'date il y a 3 mois
Sheets("Alertes").[D6].Resize([D5].CurrentRegion.Rows.Count, 4).ClearContents
For f = 0 To UBound(tabloF)
With Sheets(tabloF(f))
derligne = .Cells(Rows.Count, 2).End(xlUp).Row 'n° ligne dernière Id en colonne B
If derligne > 7 Then 'si rien sous les titres
For lig = 8 To derligne
If .Cells(lig, 5) < dtPivot Then
ReDim Preserve tabloRes(3, x)
For y = 0 To 3
tabloRes(y, x) = .Cells(lig, 2 + y)
Next y
x = x + 1
End If
Next lig
End If
End With
Next f
If x > 0 Then
ReDim tabloBis(x - 1, 3)
For ligne = 0 To x - 1
For colonne = 0 To 3
tabloBis(ligne, colonne) = tabloRes(colonne, ligne)
Next colonne
Next ligne
Sheets("Alertes").[D6].Resize(x, 4) = tabloBis
End If
End Sub