tri par ordre alphabétique

  • Initiateur de la discussion Piffard
  • Date de début
P

Piffard

Guest
Bonjour,

je cherche à faire un tri alphabétique sur pls cellules d´une ligne.
En fait 7 cellules d´une ligne comprennent chacunes une lettre.
MAIS, ayant un nombre important de ligne, je ne peux le faire ligne à ligne. Quelqu´un aurait-il une solution.

merci

Si je ne suis pas clair dans ma requête, n´hésitez pas à m´en faire part
 
Z

Zon

Guest
Salut,

Colles ceci dans un module :

Je mets le rsultat dans H2 pour tester mais le mettre dasn la 1 ere cellule de ton tableau:

Option Explicit
Dim T
Sub Princ()
Dim V
Dim I&, J&
V = Range([A2], [G65536].End(xlUp))'à adapter
For I = LBound(V, 1) To UBound(V, 1)
ReDim T(1 To UBound(V, 2))
For J = 1 To UBound(V, 2): T(J) = V(1, J): Next J
TrieTableau 1, UBound(T)
For J = 1 To UBound(V, 2): V(1, J) = T(J): Next J
Next I
Range("H2").Resize(UBound(V, 1), UBound(V, 2)) = V
End Sub
Sub TrieTableau(Deb As Long, Fin As Long) 'Ti
Dim IndiceInf As Long, IndiceSup As Long
Dim Temp1, Pivot
IndiceInf = Deb
IndiceSup = Fin
Pivot = UCase(T((Deb + Fin) \ 2))
Do
While UCase(T(IndiceInf)) < Pivot
IndiceInf = IndiceInf + 1
Wend
While Pivot < UCase(T(IndiceSup))
IndiceSup = IndiceSup - 1
Wend
If IndiceInf <= IndiceSup Then
Temp1 = T(IndiceInf)
T(IndiceInf) = T(IndiceSup)
T(IndiceSup) = Temp1
IndiceInf = IndiceInf + 1
IndiceSup = IndiceSup - 1
End If
Loop Until IndiceInf > IndiceSup
If Deb < IndiceSup Then TrieTableau Deb, IndiceSup
If IndiceInf < Fin Then TrieTableau IndiceInf, Fin
End Sub


A+++
 

Discussions similaires

  • Résolu(e)
Microsoft 365 Code de tri
Réponses
22
Affichages
438
Réponses
31
Affichages
1 K

Statistiques des forums

Discussions
312 609
Messages
2 090 193
Membres
104 449
dernier inscrit
Miguel937