Bonjour à tous
J'ai un problème avec une macro qui bug au niveau d'une ligne de tri des données.
La code complet :
L’exécution de la ligne suivante engendre une erreur 400 :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 Sub Exctraction() Exploitation = InputBox("Entrer le numéro de l'exploitation pour laquelle vous voulez faire l'extraction :") Sheets.Add.Select ActiveSheet.Name = "Exploit n°" & Exploitation ActiveSheet.Move After:=Sheets(Sheets.Count) Sheets("Extraction coop 2013").Select Selection.AutoFilter Field:=8, Criteria1:=Exploitation Dim Lg% Lg = Range("A65536").End(xlUp).Row Range("a1:k" & Lg).Copy Sheets("Exploit n°" & Exploitation).Paste Sheets("Extraction coop 2013").Select Sheets("Extraction coop 2013").ShowAllData Selection.AutoFilter Field:=10, Criteria1:=Exploitation Dim Lg2% Lg2 = Range("A65536").End(xlUp).Row Range("a2:k" & Lg2).Copy Sheets("Exploit n°" & Exploitation).Select Dim Lg3% Lg3 = Sheets("Exploit n°" & Exploitation).Range("A65536").End(xlUp).Row + 1 Sheets("Exploit n°" & Exploitation).Cells(Lg3, 1).Select ActiveSheet.Paste ActiveSheet.Range("A1").CurrentRegion.Select Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal EndSub
Je ne comprend pas d'où cela peut venir, d'autant plus que j'ai essayé d’exécuter ce bout de code indépendamment (c'est à dire que j'ai exécuter ma macro en enlevant la fonction sort à la fin, puis j'ai créer une autre macro avec seulement le sort) et ça marche très bien...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal
Merci d'avance pour votre aide.
Partager