BIZARD

  • Initiateur de la discussion OLIVIER
  • Date de début
O

OLIVIER

Guest
BONJOUR LE FORUM
VOICI 2 formule une tri en ordre decroissant et l'autre en ordre croissant avec ces formules si j'ai un doublon lorsque je tris il le compte ex
33..12..33..3..3..2 CELA DONNE EN ORDRE DECROISSANT
33 = 1
33 = 1
12 = 2
3 = 3
3 = 3
2 = 4
et ainsi de suite mais avec le tri croissant cela donne
33 = 1
33 = 2
12 = 3
3 = 4
3 = 5
2 = 6

POURQUOI ?????
VOICI LES 2 FORMULES MERCI A VOUS TOUS



Option Explicit
Sub decroissant()
Dim i As Byte, lig As Integer
Dim Plage As Range, Cell As Range
For i = 3 To 15 Step 4

Set Plage = Range(Cells(4, i), Cells(23, i + 2))
Plage.Sort Key1:=Cells(4, i), Order1:=xlDescending
For Each Cell In Range(Cells(4, i), Cells(23, i))
If Application.CountIf(Plage, Cell) = 1 Then
Cell.Offset(0, 2) = Cell.Offset(-1, 2) + 1
Else
If Cell <> Cell.Offset(-1, 0) Then
Cell.Offset(0, 2) = Cell.Offset(-1, 2) + 1
Else
Cell.Offset(0, 2) = Cell.Offset(-1, 2)
End If
End If
Next Cell
Plage.Sort Key1:=Cells(4, i + 1), Order1:=xlAscending
Next i
End Sub




Option Explicit
Sub croissant()
Dim i As Byte, lig As Integer
Dim Plage As Range, Cell As Range
For i = 19 To 24 Step 4

Set Plage = Range(Cells(4, i), Cells(23, i + 2))
Plage.Sort Key1:=Cells(4, i), Order1:=xlAscending
For Each Cell In Range(Cells(4, i), Cells(23, i))
If Application.CountIf(Plage, Cell) = 1 Then
Cell.Offset(0, 2) = Cell.Offset(-1, 2) + 1
Else
If Cell <> Cell.Offset(-1, 0) Then
Cell.Offset(0, 2) = Cell.Offset(-1, 2) + 1
Else
Cell.Offset(0, 2) = Cell.Offset(-1, 2)
End If
End If
Next Cell
Plage.Sort Key1:=Cells(4, i + 1), Order1:=xlAscending
Next i
End Sub
 

Discussions similaires

Réponses
1
Affichages
168
Réponses
0
Affichages
153
Réponses
5
Affichages
239

Statistiques des forums

Discussions
312 223
Messages
2 086 407
Membres
103 201
dernier inscrit
centrale vet