Sub Worksheet_Activate()
Dim Sh As Worksheet
IndexStore = 3
[ZoneRetard].ClearContents
' Pour toutes les feuilles
For Each Sh In ActiveWorkbook.Sheets
If Sh.Name = "Annuel" Or Sh.Name = "Facture en retard" Then GoTo EndConsolidation ' Or les feuilles inutiles
Nomfeuille = Sh.Name
IndexMax = Application.WorksheetFunction.CountA(Worksheets(Nomfeuille).Columns("A:A"))
For ligne = 3 To IndexMax
If Worksheets(Nomfeuille).Cells(ligne, 3) = "" Then
If (Now - Worksheets(Nomfeuille).Cells(ligne, 2)) >= 30 Then
For Col = 1 To 6 ' On copie les 6 colonnes
Worksheets("Facture en retard").Cells(IndexStore, Col) = _
Worksheets(Nomfeuille).Cells(ligne, Col)
Next Col
' Et on rajoute le retard en jours
Worksheets("Facture en retard").Cells(IndexStore, 3) = _
Round(Now - Worksheets(Nomfeuille).Cells(ligne, 2), 0)
' On indique le mois
Worksheets("Facture en retard").Cells(IndexStore, 7) = Nomfeuille
' On prepare l'index de la ligne suivante
IndexStore = IndexStore + 1
End If
End If
Next ligne
EndConsolidation:
Next Sh
End Sub