Répéter par ordre alphabétique une gamme spécifique de colonnes dans une feuille de calcul

J'ai une feuille de calcul excel avec le titre pour chaque colonne est sur la ligne 3.
J'aimerais savoir (via excel vba) comment réorganiser les colonnes (colonne D-Z) dans la base d'ordre alphabétique sur le nom du titre.
Merci de votre aide.

par exemple. avant d'organiser

. . . . . column D | column E | column F | column G | ... row 1 row 2 row 3 zebra | car | monkey | balloon | ... 

par exemple. après réorganisation

 . . . . . column D | column E | column F | column G | ... row 1 row 2 row 3 balloon | car | monkey | zebra | ... . . . . . . column D | column E | column F | column G | ... row 1 row 2 row 3 balloon | car | monkey | zebra | ... . . . . . . column D | column E | column F | column G | ... row 1 row 2 row 3 balloon | car | monkey | zebra | ... . . . . . . column D | column E | column F | column G | ... row 1 row 2 row 3 balloon | car | monkey | zebra | ... . . . . . . column D | column E | column F | column G | ... row 1 row 2 row 3 balloon | car | monkey | zebra | ... . . . . . . column D | column E | column F | column G | ... row 1 row 2 row 3 balloon | car | monkey | zebra | ... 

Vous avez besoin d'un algorithm de sorting et de l'appliquer aux colonnes (au lieu des lignes)

Voici un rapide et sale (ok, ce n'est pas un sortingeur super rapide, juste hors de ma memory, mais …):

 Sub HorSort(SortRange As Range, SortRow As Long) Dim Idx As Long, Jdx As Long, Kdx As Long, Tmp As Variant For Idx = 1 To (SortRange.Columns.Count - 1) For Jdx = 1 To (SortRange.Columns.Count - 1) ' compare values in row to be sorted If SortRange(SortRow, Jdx) > SortRange(SortRow, Jdx + 1) Then ' swap all cells in column with the one to the right For Kdx = 1 To SortRange.Rows.Count Tmp = SortRange(Kdx, Jdx) SortRange(Kdx, Jdx) = SortRange(Kdx, Jdx + 1) SortRange(Kdx, Jdx + 1) = Tmp Next Kdx End If Next Jdx Next Idx End Sub Sub Test() HorSort Selection, 1 End Sub 

Entrez datatables suivantes à A1

 5 2 4 1 3 ADBEC 1 2 3 4 5 

select A1..E3 et exécutez chacun de

 HorSort Selection, 1 HorSort Selection, 2 HorSort Selection, 3 

de Sub Test() . Vous n'êtes évidemment pas limité à 5 colonnes.