Voici une macro que j'ai développé, dites-moi si ça fait votre affaire.
Vous sélectionnez la colonne à trier et vous exécutez cette macro, elle va trier les enregistrements selon les données trouvées aux lignes 1,3,5,7,9, etc. en les liant avec les données de la ligne juste en dessous de chaque enregistrement.
Donc
Yves
1
Michel
2
Carl
3
René
4
va donner
Carl
3
Michel
2
René
4
Yves
1
Code :
Sub TriGroupé()
Dim ColNo As Long, i As Long, Data
ColNo = Selection.Column
Columns(ColNo + 1).Insert Shift:=xlToRight
i = 0
Do Until Cells(i * 2 + 1, ColNo).Value = ""
Valeur = Cells(i * 2 + 1, ColNo).Value & "×" & i + 1
Cells(i + 1, ColNo + 1).Value = Valeur
i = i + 1
Loop
Columns(ColNo + 1).Sort Key1:=Range(Cells(1, ColNo + 1), Cells(1, ColNo + 1)), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Columns(ColNo + 2).Insert Shift:=xlToRight
i = 0
Do Until Cells(i * 2 + 1, ColNo).Value = ""
Data = Split(Cells(i + 1, ColNo + 1).Value, "×")
Cells(i * 2 + 1, ColNo + 2).Value = Data(0)
Cells(i * 2 + 2, ColNo + 2).Value = Cells((CLng(Data(1))) * 2, ColNo)
i = i + 1
Loop
Columns(ColNo + 1).Delete Shift:=xlToLeft
Columns(ColNo).Delete Shift:=xlToLeft
Columns(ColNo).Select
End Sub