job75
XLDnaute Barbatruc
Bonjour à tous,
Pour faire suite à une demande d'hier de l'ami Si... voyez le fichier joint et ces 2 macros :
Sur Win XP - Excel 2003 le filtre par tableau est 2,5 fois plus rapide.
A+
Pour faire suite à une demande d'hier de l'ami Si... voyez le fichier joint et ces 2 macros :
Code:
Sub Filtre1() 'par tableau
Dim t, crit, tablo, i&, n&, j As Byte
t = Timer
crit = [H1]
tablo = [A2:D10001] 'à adapter
For i = 1 To UBound(tablo)
If tablo(i, 1) = crit Then
n = n + 1
For j = 1 To 4
tablo(n, j) = tablo(i, j)
Next
End If
Next
With Feuil2.[A2:D65536]
.ClearContents 'RAZ
If n Then .Resize(n, 4) = tablo
.Parent.Activate
End With
MsgBox "Durée " & Format(Timer - t, "0.00 \s")
End Sub
Sub Filtre2() 'automatique
Dim t, crit
t = Timer
crit = [H1]
With Feuil2.[A1:D65536]
.ClearContents 'RAZ
[A1:D10001].AutoFilter 1, crit 'à adapter
[A1:D10001].SpecialCells(xlCellTypeVisible).Copy .Cells(1)
ActiveSheet.AutoFilterMode = False
.Parent.Activate
End With
MsgBox "Durée " & Format(Timer - t, "0.00 \s")
End Sub
A+
Pièces jointes
Dernière édition: