Bonjour à tous ,
Une méthode un peu plus compliquée mais plutôt rapide.
Le classeur joint supprime les lignes du tableau comportant "Catégorie" en colonne C ou comportant "TOTAL" en colonne D. Cliquer sur le bouton Hop!
Sur ma bécane, pour 20 000 lignes dans la base, la durée d'exécution est de 0,11 s pour 3 425 lignes supprimées.
Le code dans Module1 :
Sub SupprLignes()
Dim der&, deb, der2&
deb = Timer
With Sheets("data")
If .FilterMode Then .ShowAllData
der = .Cells(Rows.Count, "a").End(xlUp).Row
If der = 1 Then Exit Sub
Application.ScreenUpdating = False
.Columns("a:a").Insert
On Error GoTo FIN
.Cells(2, "a").Formula = "=IF(OR(d2=""Catégorie"",e2=""TOTAL""),NA(),ROW())"
' .Cells(2, "a").Formula = "=IF(e2=""TOTAL"",NA(),ROW())" '<<<<<< réactiver la ligne pour ne supprimer que les lignes "TOTAL"
.Range("a2").AutoFill Destination:=.Range("a2:a" & der)
.Range("a2:a" & der).Value = .Range("a2:a" & der).Value
.Range("a1:g1").Resize(der).Sort key1:=.Range("a1"), order1:=xlAscending, Header:=xlYes
On Error Resume Next
.Range("a1:a" & der).SpecialCells(xlCellTypeConstants, xlErrors).Resize(, 7).Delete xlShiftUp
FIN:
On Error GoTo 0
der2 = .Cells(Rows.Count, "a").End(xlUp).Row
.Columns("a:a").Delete
End With
MsgBox (der - der2) & " lignes supprimée(s) en " & Format(Timer - deb, "#,##0.0\ sec.")
End Sub