Tri personnalisé

Bonjour,

Je souhaite automatisé un tri personnalisé à partir d'une liste personnalisé mais cela ne fonctionne pas.

maplage.Sort Key1:=Range("A2"), CustomOrder:="Assortiment,Entrée,Plat,Dessert"

J'ai un soucis avec customOrder.

Bigben2013 a écrit :

Bonjour,

Je souhaite automatisé un tri personnalisé à partir d'une liste personnalisé mais cela ne fonctionne pas.

maplage.Sort Key1:=Range("A2"), CustomOrder:="Assortiment,Entrée,Plat,Dessert"

J'ai un souci avec customOrder.

une solution avec l'objet sort plutot que la méthode range.sort

Sub test()

 With ActiveWorkbook.Worksheets(ActiveSheet.Name).Sort
        .SortFields.Clear
        .SortFields.Add Key:=Range("A1:A20"), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal, _
            CustomOrder:="Assortiment,Entrée,Plat,Dessert"
        .SetRange Range("A1:B20")
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With

End Sub

Merci cela fonctionne très bien

Rechercher des sujets similaires à "tri personnalise"