Bonjour !
Alors voilà, j'ai créé tout un programme qui fait pleins de bidouilles pour récupérer des données. Jusqu'ici je m'en sortais. Mais je veux maintenant trier ces données suivant une colonne en me basant sur une liste de valeurs spécifique. J'ai donc utilisé l'enregistreur de macro et j'obtiens ce code :
Que je modifie pour correspondre a mon code par :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 Columns("D:D").Select ActiveWorkbook.Worksheets("05.10.039.3").Sort.SortFields.Clear ActiveWorkbook.Worksheets("05.10.039.3").Sort.SortFields.Add Key:=Range( "D1:D12"), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:="Chantier,Statut,CC,EC", DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("05.10.039.3").Sort .SetRange Range("A1:AK12") .Header = xlGuess .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With
Le résultat : Les cellules sont bien sélectionnées mais le trie ne s'est pas fait. Par contre si je test de le faire à la main juste après ça fonctionne ben. Alors je ne comprends pas pourquoi le "trie ne se fait pas"....
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 Range("D1:D" & Range("A65536").End(xlUp).Row).Select ActiveSheet.Sort.SortFields.Clear ActiveSheet.Sort.SortFields.Add Key:=Range( _ "D1:D" & Range("A65536").End(xlUp).Row), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= "Chantier,Statut,CC,EC", DataOption:=xlSortNormal With ActiveSheet.Sort .SetRange Range("A1:AK12") .Header = xlGuess .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With
Si quelqu'un comprend
Partager