Multi-colonne de tri à l'aide de VBA

Je suis à l'aide de VBA pour trier les colonnes dans Excel 2003. J'ai besoin de trier par colonne 5 ascendant, puis la colonne 3 à l'aide d'une commande personnalisée, puis par la colonne 4 de l'ascendant. Je vais avoir de la difficulté à obtenir le genre de travail et je ne suis pas totalement comprendre comment OrderCustom s'applique.

Tous les pointeurs dans la bonne direction serait apprécié 🙂 Mon code est ci-dessous.

With wsData
    lastrow = .Cells(Rows.Count, 1).End(xlUp).Row + 1
    lastCol = .Cells(4, Columns.Count).End(xlToLeft).Column

    Dim n As Long
    Application.AddCustomList ListArray:=Array("LOW", "MEDIUM OR HIGH", "HIGH ONLY")
    n = Application.GetCustomListNum(Array("LOW", "MEDIUM OR HIGH", "HIGH ONLY")) + 1

    Dim strSortOrder As String
    .Range(.Cells(1, 1), .Cells(lastrow, lastCol)).Sort _
        Key1:=.Range(.Cells(2, 5), .Cells(lastrow, lastCol)), Order1:=xlAscending, _
        Key2:=.Range(.Cells(2, 3), .Cells(lastrow, lastCol)), Order2:=xlDescending, _
        Key3:=.Range(.Cells(2, 4), .Cells(lastrow, lastCol)), Order3:=xlDescending, _
        OrderCustom:=n, _
        MatchCase:=False, Orientation:=xlSortColumns, Header:=xlYes
End With

OriginalL'auteur Echilon | 2009-09-20