1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
Sub Suppr_doublons()
'
' Suppr_doublons Macro
' Macro enregistrée le 08/11/2007
'
'Copie de la colonne article
Sheets("Extract. Article").Select
Range([D2], [D2].End(xlDown)).Select
Selection.Copy
Sheets("Feuil5").Select
Range("A2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
'Tri de la colonne article
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
'Formule pour identifier les doublons
Range("B2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]=R[-1]C[-1],""1"","""")"
Range("B2").Select
Selection.AutoFill Destination:=Range(ActiveCell, ActiveCell.Offset(0, -1).End(xlDown).Offset(0, 1))
'Copier/coller spécial valeurs des deux colonnes A et B
Range([A2], [A2].End(xlDown).Offset(0, 1)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
'Trouver la 1ère valeur "1"
Range("B2").End(xlDown).Activate
Range(ActiveCell.Offset(-1, 0), ActiveCell.End(xlDown)).Select
Selection.Delete
End Sub |
Partager