• Initiateur de la discussion Initiateur de la discussion GHISLAIN
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

GHISLAIN

XLDnaute Impliqué
Bonjour a tous

je voudrai savoir si il existe un code plus simple pouvant me servir a trier mes colonnes par ordre croissant en vba

le code que j utilise actuellement est celui ci dessous:

Sheets("lLISTE").Select
Range("C7:C42").Select
ActiveSheet.Unprotect
Selection.Sort Key1:=Range("C7"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Range("D7😀42").Select
Selection.Sort Key1:=Range("D7"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Range("E7:E42").Select
Selection.Sort Key1:=Range("E7"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Range("F7:F42").Select
Selection.Sort Key1:=Range("F7"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Range("G7:G42").Select
Selection.Sort Key1:=Range("G7"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Range("H7:H42").Select
Selection.Sort Key1:=Range("H7"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Range("I7:I42").Select
Selection.Sort Key1:=Range("I7"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Range("J7:J42").Select
Selection.Sort Key1:=Range("J7"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Range("K7:K42").Select
Selection.Sort Key1:=Range("K7"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Range("L7:L42").Select
Selection.Sort Key1:=Range("L7"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

et ainsi de suite jusqu'a ap7 : ap42

Merci a tous des solutions apportées et de votre aide

Amicalement

GHISLAIN
 
Re : Tri colonne

bonjour GHISLAIN

Teste ceci

Code:
Sheets("lLISTE").Select
ActiveSheet.Unprotect
For n = 3 To 42
ActiveSheet.Range(Cells(7, n), Cells(42, n)).Sort Key1:=Cells(7, n), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Next n
ActiveSheet.Protect
 
Re : Tri colonne

Bonjour PierreJean

merci deja pour ta rapidité de reponse et comme a son habitude son efficacité d'execution

afin de compléter ce code et raccourcir son délai d'execution serai t'il possible de rajouter dans ce code pour qu'il ne tienne compte que des colonnes ou le titre de colonne celule 6 de chaque colonne est rempli pour effectuer le tri
a savoir que les colonnes remplies ne sont pas toute a la suite et peuvent etre separer par une ou plusieurs colonnes vides .

merci de ton aide

amicalement

ghislain
 
Re : Tri colonne

Re

A tester:

Code:
Sheets("lLISTE").Select
ActiveSheet.Unprotect
Application.ScreenUpdating = False
For n = 3 To 42
If ActiveSheet.Cells(6, n) <> "" Then
 ActiveSheet.Range(Cells(7, n), Cells(42, n)).Sort Key1:=Cells(7, n), Order1:=xlAscending, Header:=xlNo, _
 OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
 DataOption1:=xlSortNormal
End If
Next n
Application.ScreenUpdating = True
ActiveSheet.Protect
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
17
Affichages
1 K
Réponses
5
Affichages
481
Réponses
6
Affichages
1 K
Réponses
11
Affichages
780
Retour