A Gloub,
(A Tulipe_4)
Mon code prend en compte un nombre de lignes indéterminée.
Il supprime tous les éléments communiqués par Gloub (à savoir les AF,NV,NSV & HM
La formule de Tulipe_4 est fonctionnelle, mais difficilement compréhensible par le commun des Exceliens. Donc difficile à reproduire.
Mon code répond à la question posée, sans information complémentaire de la part de Gloub.
Quant à la fonction d'automatisme, il est clair que l'on démarre sa voiture sans action préalable
Cdlt.
Pour le problème de compabilité 2003/2010, je joins le code:
Option Explicit
Public Sub Mise_en_Forme()
Dim derLigne As Integer
Dim i As Integer
Application.ScreenUpdating = False
Range("A1").CurrentRegion.Select
Selection.Copy
Range("E1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
derLigne = Range("G" & Rows.Count).End(xlUp).Row
'MsgBox derLigne
For i = derLigne To 2 Step -1
'MsgBox i
If Cells(i, 6) = "AF" Or Cells(i, 6) = "NV" Or Cells(i, 6) = "NSV" _
Or Cells(i, 6) = "HM" Or Cells(i, 6) = "R" Then
Range(Cells(i, 5), Cells(i, 7)).Select
Selection.Delete Shift:=xlUp
End If
Next i
derLigne = Range("G" & Rows.Count).End(xlUp).Row
Range("E1").CurrentRegion.Select
ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear
ActiveWorkbook.ActiveSheet.Sort.SortFields.Add Key:=Range(Cells(2, 7), Cells(derLigne, 7)), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.ActiveSheet.Sort
.SetRange Range("E1").CurrentRegion
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub