Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim deb As Date, fin As Date, t1, t2, tablo, I&, n&, Ws As Worksheet, Col As Byte
With Sh
If .Name Like "Taxe*" Then 'critère
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual 'calcul manuel
deb = DateSerial([An], .[G5], 1)
fin = DateSerial([An], .[H5] + 1, 1)
.Rows.Hidden = False 'RAZ
.[A10:C72,H10:H72] = "" 'RAZ
t1 = .[A10:C72]: t2 = [H10:H72]
For Each Ws In Sheets(Array(Feuil1.Name, Feuil10.Name))
Col = IIf(Ws.Name = Feuil1.Name, 27, 43)
tablo = Ws.[A1].CurrentRegion.Resize(, Col) 'matrice, plus rapide
For I = 2 To UBound(tablo)
If tablo(I, 2) >= deb And tablo(I, 2) < fin And tablo(I, 12) = "Convention" Then
n = n + 1
If n < 64 Then 'sécurité
t1(n, 1) = tablo(I, 2): t1(n, 2) = tablo(I, 3)
t1(n, 3) = tablo(I, 43): t2(n, 1) = tablo(I, 10)
End If
End If
Next
Next
.[A10:C72] = t1: .[H10:H72] = t2
.[A10:H72].Sort .[A10], xlAscending, Header:=xlNo 'tri
If n < 63 Then .Rows(n + 10 & ":72").Hidden = True 'Total en ligne 73
Application.Calculation = xlCalculationAutomatic
End If
End With
End Sub