re-bonjour,
j'ai adapté la macro
elle mémorise la position initiale des lignes
elle trie le tableau
execute les suppressions de lignes
restaure le tableau sans les lignes supprimées dans l'ordre initial
Sub aargh()
With Sheets("sheet1")
dl = .Cells(.Rows.Count, 1).End(xlUp).Row
.Columns(5).Insert shift:=xlToRight
For i = 1 To dl
.Cells(i, 5) = i
Next i
.Range("A1:E" & dl).Sort key1:=.Range("C1"), order1:=xlAscending, key2:=.Range("D1"), order2:=xlAscending, Header:=xlYes
cl = ""
cd = ""
For i = dl To 1 Step -1
If cl <> .Cells(i, 3) Then
If b And c Then .Rows(lr & ":" & fr).Delete shift:=xlUp
b = False
c = False
fr = i
cl = .Cells(i, 3)
End If
lr = i
If cd <> .Cells(i, 4) Then
If Not (b And c) Then
c = False
b = False
End If
cd = .Cells(i, 4)
End If
If .Cells(i, 2) = "Chevres" Then
c = True
ElseIf .Cells(i, 2) = "Brebis" Then
b = True
End If
Next i
dl = .Cells(.Rows.Count, 1).End(xlUp).Row
.Range("A1:E" & dl).Sort key1:=.Range("E1"), order1:=xlAscending, Header:=xlYes
.Columns(5).Delete shift:=xlToLeft
End With
End Sub