Erreur de compilation

Bonjour,

Je suis passée par l'enregistrement d'une macro pour pourvoir effectuer un tri alphabétique dans un tableau et j'ai un message d'erreur de compilation : Argument non facultatif.

J'ai beau cherché et ne trouve rien pour résoudre cette erreur.

Sub TRI()

Range("Tableau1").Select
    Application.CutCopyMode = False
    ActiveWorkbook.Worksheets("BD").ListObjects("Tableau1").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("BD").ListObjects("Tableau1").Sort.SortFields.Add _
        Key:=Range("A2"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
        :=xlSortNormal
    With ActiveWorkbook.Worksheets("BD").ListObjects("Tableau1").Sort
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
End Sub

Merci pour votre aide.

Bonjour,

ci-dessous code à appliquer (select inutile):

    With ActiveWorkbook.Worksheets("BD").ListObjects("Tableau1")
        .Range.Sort key1:=.ListColumns(1), order1:=xlAscending, _
        Header:=xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    End With

Bonjour,

Ceci fonctionne chez moi :

Sub TRI()

    Dim Tbl As ListObject

    Set Tbl = Worksheets("BD").ListObjects("Tableau1")

    With Tbl

        .Sort.SortFields.Clear
        .Sort.SortFields.Add [A1], 0, 1, , 0

        With .Sort

            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply

        End With

    End With

End Sub

Merci beaucoup cela fonctionne

Rechercher des sujets similaires à "erreur compilation"