Bonjour à tous,

J'ai un petit souci dans mon code, pour trier un tableau excel de 4 colonnes. Je trie les colonnes par rapport à une des colonnes qui contient des valeurs. Les valeurs non triées ça donne:

3 818 058,27
906 400,95
2 582 014,24
1 504 552,73
507 835,79
4 178 915,38
682 537,21
580 020,68
588 671,53
15 318,10
154 827,48
790 099,12
894 170,19
17 382,56
122 052,20
1 284 652,18
474 193,87
1 706 941,74
900 610,71
368 430,82
269 124,55
1 693 145,09
1 364 596,57
15 251,08
1 263 898,88
1 549 297,45
18 063,67
189 735,91
1 630 752,61
738 898,86
183 466,81
86 601,10
661 090,41
93 936,09
34 817,45
462 335,88
628 288,27
107 054,01
51 581,28
451 842,71
11 471,35
2 329,73
12 036,04
3 331,61
187 068,93
-9 281,72
120 492,93
4 324,21
170 034,17
51 532,89
17 727,80
232 289,17
564 337,62
2 598,39
0,00
70 609,30
76 394,27
632,06
3 627,08
99 544,97
19 476,13
85 316,86
38 959,48
273 213,68
48 846,16
328 045,31
555,71
56 477,02
-77,38
Après tri (avec anomalies):

4 178 915,38
3 818 058,27
906 400,95
2 582 014,24
1 706 941,74
1 693 145,09
1 630 752,61
1 549 297,45
1 504 552,73
1 364 596,57
1 284 652,18
1 263 898,88
900 610,71
894 170,19
790 099,12
738 898,86
682 537,21
661 090,41
628 288,27
588 671,53
580 020,68
564 337,62
507 835,79
474 193,87
462 335,88
451 842,71
368 430,82
328 045,31
273 213,68
269 124,55
232 289,17
189 735,91
187 068,93
183 466,81
170 034,17
154 827,48
122 052,20
120 492,93
107 054,01
99 544,97
93 936,09
86 601,10
85 316,86
76 394,27
70 609,30
56 477,02
-9 281,72
51 581,28
51 532,89
48 846,16
38 959,48
34 817,45
19 476,13
18 063,67
17 727,80
17 382,56
15 318,10
15 251,08
12 036,04
11 471,35
4 324,21
2 598,39
3 627,08
3 331,61
2 329,73
-77,38
632,06
555,71
0,00
Le code utilisé:

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
	       For Each c In .Range("F4:F" & derniereCellContinent)
 
			max = c.Value
 
			For Each d In .Range("F" & c.row & ":F" & derniereCellContinent)
 
				If(d.Value > max) Then
 
					Debug.Print cpt
					max = d.Value
					maxLig = d.Row
 
				End If
 
			Next d
 
			tempF = c.Value
			tempE = .Range("E" & c.row)
			tempG = .Range("G" & c.Row)
			tempH = .Range("H" & c.Row)
 
			c.Value = .Range("F" & maxLig).Value
			.Range("E" & c.row) = .Range("E" & maxLig)
			.Range("G" & c.Row) = .Range("G" & maxLig)
			.Range("H" & c.Row) = .Range("H" & maxLig)
 
			.Range("E" & maxLig).Value = tempE
			.Range("F" & maxLig).Value = tempF
			.Range("G" & maxLig).Value = tempG
			.Range("H" & maxLig).Value = tempH
 
		Next c
Trois valeurs ne sont donc pas bonnes, mais je ne comprends pas pourquoi.

Merci d'avance pour votre aide.