Sub Cheezy2()
Dim dest As Range
With Sheets("CDES EXPEDIEES")
If .FilterMode Then .ShowAllData 'si la feuille est filtrée
Set dest = .Cells(.Cells(.Rows.Count, 7).End(xlUp).Row + 1, 1)
End With
Application.ScreenUpdating = False
With Sheets("Commandes")
If Application.CountIf(.Columns(7), "CDE EXPEDIEE") Then
With .Range("A1", .UsedRange)
.Columns(7).EntireColumn.Insert 'insère une colonne auxiliaire
.Columns(7) = "=1/(RC[1]=""CDE EXPEDIEE"")/(ROW()>1)" 'formule du filtrage
.Columns(7) = .Columns(7).Value 'supprime les formules
.Sort .Columns(7), xlDescending, Header:=xlYes 'tri pour regrouper et accélérer
With .Columns(7).SpecialCells(xlCellTypeConstants, 1).EntireRow
.Copy dest
.Delete 'supprime les lignes copiées
End With
dest(1, 7).Resize(Rows.Count - dest.Row + 1).Delete xlToLeft
.Columns(7).EntireColumn.Delete 'supprime la colonne auxiliaire
End With
End If
If Application.CountA(dest(0).EntireRow) = 0 Then .Rows(1).Copy dest(0) 'ligne des titres
End With
End Sub