Modifier une macro

Bonjour, j'ai une macro qui supprime les doublons se situant dans la colonne A feuille1, comment la modifier pour avoir la liste sans doublons dans la colonne A ligne 3 de la feuille2 et non pas dans la cellule d2 de la feuille1?

Sub SupprDoublons()

Range("a2:a" & [a65000].End(xlUp).Row).Select

Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _

OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _

DataOption1:=xlSortNormal

Range("A2").Select

Range("a2:a" & [a65000].End(xlUp).Row).AdvancedFilter Action:=xlFilterCopy, _

CopyToRange:=Range("d2"), Unique:=True

End Sub

Sub SupprDoublons()

Range("a2:a" & [a65000].End(xlUp).Row).Select

Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _

OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _

DataOption1:=xlSortNormal

Range("A2").Select

Range("a2:a" & [a65000].End(xlUp).Row).AdvancedFilter Action:=xlFilterCopy, _

CopyToRange:=Range("d2"), Unique:=True

End Sub

Bonjour,

Teste ceci :

Sub SupprDoublons()

    Dim Plage As Range

    With Worksheets("Feuil1")

        Set Plage = .Range(.Cells(2, 1), .Cells(.Rows.Count, 1).End(xlUp))

    End With

    Plage.Sort Range("A2"), xlAscending, , , , , , xlGuess, 1, , xlTopToBottom

    Plage.AdvancedFilter xlFilterCopy, , Worksheets("Feuil2").Range("A3"), True

End Sub

Hervé.

J'ai essayé le code au dessus mais il bloque:

Sub Suppr()

Dim Plage As Range

With Worksheets("Feuil1")

Set Plage = .Range(.Cells(2, 1), .Cells(.Rows.Count, 1).End(xlUp))

End With

Plage.Sort Range("AY2"), xlAscending, , , , , , xlGuess, 1, , xlTopToBottom Plage.AdvancedFilter xlFilterCopy, , Worksheets("Garage").Range("A3"), True

End Sub

Bonsoir,

Solution pour Excel 2010

Option Explicit
Public Sub Copie_sans_doublons()
Dim Wss As Worksheet, Wsd As Worksheet
Dim Derligne As Long

    Application.ScreenUpdating = False
    Set Wss = Worksheets("Feuil1") ' Feuille source
    Set Wsd = Worksheets("Feuil2") ' feuille de destination
    With Wss
        Derligne = .Range("A" & Rows.Count).End(xlUp).Row
        .Range("A1:A" & Derligne).Copy Destination:=Wsd.Cells(3, 1)
    End With
    Wsd.Range("A3:A" & Derligne + 2).RemoveDuplicates Columns:=1, Header:=xlNo
    Set Wss = Nothing: Set Wsd = Nothing
End Sub

nota : sinon

Plage.Sort Range("AY2"), xlAscending

est différent de (proposition de These)

Plage.Sort Range("A2"), xlAscending

Re,

Si tu recopie de cette façon :

Plage.Sort Range("AY2"), xlAscending, , , , , , xlGuess, 1, , xlTopToBottom Plage.AdvancedFilter xlFilterCopy, , Worksheets("Garage").Range("A3"), True

Il est évident que ça ne peut pas fonctionner car deux instructions qui se suivent sans les deux points de séparation génère une erreur !

Il est nécessaire que le code soit recopié comme il est posté.

Hervé.

Rechercher des sujets similaires à "modifier macro"