Private Sub Worksheet_Activate()
Worksheet_Change [B5] 'lance la macro
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, [B5]) Is Nothing Then Exit Sub
Dim code$, w As Worksheet, tablo, i&, n&
code = CStr([B5])
If code <> "" Then
ReDim resu(1 To Rows.Count, 1 To 3)
For Each w In Worksheets
If IsNumeric(w.Name) Then
tablo = w.Range("A1", w.UsedRange).Resize(, 7)
For i = 1 To UBound(tablo)
If tablo(i, 3) = code Then
n = n + 1
resu(n, 1) = tablo(i, 6)
resu(n, 2) = tablo(i, 2)
resu(n, 3) = tablo(i, 5)
End If
Next i
End If
Next w
End If
'---restitution---
If FilterMode Then ShowAllData 'si la feuille est filtrée
With [D5]
If n Then .Resize(n, 3) = resu
.Offset(, -1) = n 'en C5
.Offset(n).Resize(Rows.Count - n - .Row + 1, 3).ClearContents 'RAZ en dessous
End With
With UsedRange: End With 'actualise la barre de défilement verticale
End Sub