J'ai trouv=E9 une macro qui permet de trier par ordre alphabetiques les
mots-chaines de caract=E8res s=E9par=E9s par des virgules =E0 l'int=E9rieur
d'une cellule. Cette macro prend en compte la cellule active.
J'aimerais pouvoir la modifier afin q"'elle agisse sur la plage de
cellules Range("AE2:AE" & [AE2].End(xlDown).Row)
Merci par avance de votre aide.
Christophe
Sub TriCellule()
'
' TriCellule Macro
' La fonction Split transforme une cha=EEne en tableau
' La fonction Join fait l'inverse
'
Dim Chn As String, Tri As Boolean, I As Integer, Tmp As String
Chn =3D ActiveCell.Text
If Chn =3D "" Then Exit Sub
TbChn =3D Split(Chn, ",")
If UBound(TbChn) > 0 Then
Do
Tri =3D False
For I =3D 1 To UBound(TbChn)
If TbChn(I) < TbChn(I - 1) Then
Tmp =3D TbChn(I - 1)
TbChn(I - 1) =3D TbChn(I)
TbChn(I) =3D Tmp
Tri =3D True
End If
Next
Loop While Tri =3D True
Chn =3D Join(TbChn, ",")
ActiveCell.Value =3D Chn
End If
'
End Sub
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
JB
Bonjour,
Sub TriChamp() For Each c In Range("AE2:AE" & [AE2].End(xlDown).Row) temp = Split(c, ",") For I = LBound(temp) To UBound(temp) For j = I To UBound(temp) If temp(j) < temp(I) Then tempo = temp(j) temp(j) = temp(I) temp(I) = tempo End If Next j Next I c.Value = Join(temp, ",") Next c End Sub
JB
On 9 avr, 10:33, Christophe wrote:
Bonjour:
J'ai trouvé une macro qui permet de trier par ordre alphabetiques les mots-chaines de caractères séparés par des virgules à l'intérieu r d'une cellule. Cette macro prend en compte la cellule active. J'aimerais pouvoir la modifier afin q"'elle agisse sur la plage de cellules Range("AE2:AE" & [AE2].End(xlDown).Row)
Merci par avance de votre aide.
Christophe
Sub TriCellule() ' ' TriCellule Macro ' La fonction Split transforme une chaîne en tableau ' La fonction Join fait l'inverse ' Dim Chn As String, Tri As Boolean, I As Integer, Tmp As String Chn = ActiveCell.Text If Chn = "" Then Exit Sub TbChn = Split(Chn, ",") If UBound(TbChn) > 0 Then Do Tri = False For I = 1 To UBound(TbChn) If TbChn(I) < TbChn(I - 1) Then Tmp = TbChn(I - 1) TbChn(I - 1) = TbChn(I) TbChn(I) = Tmp Tri = True End If Next Loop While Tri = True Chn = Join(TbChn, ",") ActiveCell.Value = Chn End If ' End Sub
Bonjour,
Sub TriChamp()
For Each c In Range("AE2:AE" & [AE2].End(xlDown).Row)
temp = Split(c, ",")
For I = LBound(temp) To UBound(temp)
For j = I To UBound(temp)
If temp(j) < temp(I) Then
tempo = temp(j)
temp(j) = temp(I)
temp(I) = tempo
End If
Next j
Next I
c.Value = Join(temp, ",")
Next c
End Sub
JB
On 9 avr, 10:33, Christophe <cj...@mail.doc.gov> wrote:
Bonjour:
J'ai trouvé une macro qui permet de trier par ordre alphabetiques les
mots-chaines de caractères séparés par des virgules à l'intérieu r
d'une cellule. Cette macro prend en compte la cellule active.
J'aimerais pouvoir la modifier afin q"'elle agisse sur la plage de
cellules Range("AE2:AE" & [AE2].End(xlDown).Row)
Merci par avance de votre aide.
Christophe
Sub TriCellule()
'
' TriCellule Macro
' La fonction Split transforme une chaîne en tableau
' La fonction Join fait l'inverse
'
Dim Chn As String, Tri As Boolean, I As Integer, Tmp As String
Chn = ActiveCell.Text
If Chn = "" Then Exit Sub
TbChn = Split(Chn, ",")
If UBound(TbChn) > 0 Then
Do
Tri = False
For I = 1 To UBound(TbChn)
If TbChn(I) < TbChn(I - 1) Then
Tmp = TbChn(I - 1)
TbChn(I - 1) = TbChn(I)
TbChn(I) = Tmp
Tri = True
End If
Next
Loop While Tri = True
Chn = Join(TbChn, ",")
ActiveCell.Value = Chn
End If
'
End Sub
Sub TriChamp() For Each c In Range("AE2:AE" & [AE2].End(xlDown).Row) temp = Split(c, ",") For I = LBound(temp) To UBound(temp) For j = I To UBound(temp) If temp(j) < temp(I) Then tempo = temp(j) temp(j) = temp(I) temp(I) = tempo End If Next j Next I c.Value = Join(temp, ",") Next c End Sub
JB
On 9 avr, 10:33, Christophe wrote:
Bonjour:
J'ai trouvé une macro qui permet de trier par ordre alphabetiques les mots-chaines de caractères séparés par des virgules à l'intérieu r d'une cellule. Cette macro prend en compte la cellule active. J'aimerais pouvoir la modifier afin q"'elle agisse sur la plage de cellules Range("AE2:AE" & [AE2].End(xlDown).Row)
Merci par avance de votre aide.
Christophe
Sub TriCellule() ' ' TriCellule Macro ' La fonction Split transforme une chaîne en tableau ' La fonction Join fait l'inverse ' Dim Chn As String, Tri As Boolean, I As Integer, Tmp As String Chn = ActiveCell.Text If Chn = "" Then Exit Sub TbChn = Split(Chn, ",") If UBound(TbChn) > 0 Then Do Tri = False For I = 1 To UBound(TbChn) If TbChn(I) < TbChn(I - 1) Then Tmp = TbChn(I - 1) TbChn(I - 1) = TbChn(I) TbChn(I) = Tmp Tri = True End If Next Loop While Tri = True Chn = Join(TbChn, ",") ActiveCell.Value = Chn End If ' End Sub