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 !

13Christian

XLDnaute Nouveau
Bonjour à tous ,
Dans un onglet de mon fichier excel , j'ai plusieurs colonnes jointives de données que je viens trier individuellement (colonne par colonne) . Mais le résultat final est que mon code VBA se comporte comme si je permettais une extension a l'ensemble des cellules à proximités et qu'en suite je faisait mon tri . Je vous communique ma macro qui me permet cela , et attent avec impatience vos réponses .
Merci par avance

Christian

Private Sub ListesAutres()
Dim FinListingCivilité As Integer
Dim FinListingType As Integer
Dim FinListingMatière As Integer
Dim FinListingContrat As Integer
Dim FinListingClient As Integer
Dim FinListingTaille As Integer
Dim FinListingIndex As Integer
Dim FinListingFournisseur As Integer
Dim FinListingCouleur As Integer
Dim FinListingFermeture As Integer
FinListingCivilité = Worksheets("dB").Range("G65536").End(xlUp).Row
FinListingType = Worksheets("dB").Range("I65536").End(xlUp).Row
FinListingMatière = Worksheets("dB").Range("J65536").End(xlUp).Row
FinListingContrat = Worksheets("dB").Range("H65536").End(xlUp).Row
FinListingClient = Worksheets("Client").Range("A65536").End(xlUp).Row
FinListingTaille = Worksheets("dB").Range("L65536").End(xlUp).Row
FinListingIndex = Worksheets("dB").Range("M65536").End(xlUp).Row
FinListingFournisseur = Worksheets("dB").Range("P65536").End(xlUp).Row
FinListingCouleur = Worksheets("dB").Range("Q65536").End(xlUp).Row
FinListingFermeture = Worksheets("dB").Range("R65536").End(xlUp).Row
If FinListingCivilité = 13 Then
UserForm2.ComboBox1.RowSource = "dB!G11:dB!G13"
ElseIf FinListingCivilité > 13 Then
Worksheets("dB").Range("G14:G" & FinListingCivilité).Sort Key1:=Worksheets("dB").Range("G14"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
UserForm2.ComboBox1.RowSource = "dB!G11:dB!G" & FinListingCivilité
End If
If FinListingType = 11 Then
With UserForm1
.ComboBox2.RowSource = ""
.ComboBox11.RowSource = "dB!I11:dB!I11"
.ComboBox17.RowSource = ""
End With
ElseIf FinListingType > 11 Then
Worksheets("dB").Range("I12:I" & FinListingType).Sort Key1:=Worksheets("dB").Range("I12"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With UserForm1
.ComboBox2.RowSource = "dB!I12:dB!I" & FinListingType
.ComboBox11.RowSource = "dB!I11:dB!I" & FinListingType
.ComboBox17.RowSource = "dB!I12:dB!I" & FinListingType
End With
End If
If FinListingMatière = 11 Then
With UserForm1
.ComboBox3.RowSource = ""
.ComboBox9.RowSource = "dB!J11:dB!J11"
.ComboBox15.RowSource = ""
End With
ElseIf FinListingMatière > 11 Then
Worksheets("dB").Range("J12:J" & FinListingMatière).Sort Key1:=Worksheets("dB").Range("J12"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With UserForm1
.ComboBox3.RowSource = "dB!J12:dB!J" & FinListingMatière
.ComboBox9.RowSource = "dB!J11:dB!J" & FinListingMatière
.ComboBox15.RowSource = "dB!J12:dB!J" & FinListingMatière
End With
End If
If FinListingContrat <= 11 Then
UserForm1.ComboBox5.RowSource = "dB!H11:dB!H11"
ElseIf FinListingContrat > 11 Then
Worksheets("dB").Range("H11:H" & FinListingContrat).Sort Key1:=Worksheets("dB").Range("H11"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
UserForm1.ComboBox5.RowSource = "dB!H11:dB!H" & FinListingContrat
End If
If FinListingTaille = 11 Then
With UserForm1
.ComboBox4.RowSource = ""
.ComboBox10.RowSource = "dB!L11:dB!L11"
.ComboBox16.RowSource = ""
End With
ElseIf FinListingTaille > 11 Then
Worksheets("dB").Range("L12:L" & FinListingTaille).Sort Key1:=Worksheets("dB").Range("L12"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With UserForm1
.ComboBox4.RowSource = "dB!L12:dB!L" & FinListingTaille
.ComboBox10.RowSource = "dB!L11:dB!L" & FinListingTaille
.ComboBox16.RowSource = "dB!L12:dB!L" & FinListingTaille
End With
End If
If FinListingIndex <= 11 Then
UserForm1.ComboBox6.RowSource = "dB!M11:dB!M11"
ElseIf FinListingIndex > 11 Then
Worksheets("dB").Range("M11:M" & FinListingIndex).Sort Key1:=Worksheets("dB").Range("M11"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
UserForm1.ComboBox6.RowSource = "dB!M11:dB!M" & FinListingIndex
End If
If FinListingFournisseur = 11 Then
With UserForm1
.ComboBox14.RowSource = ""
.ComboBox12.RowSource = "dB!P11:dB!P11"
End With
ElseIf FinListingFournisseur > 11 Then
Worksheets("dB").Range("P12😛" & FinListingFournisseur).Sort Key1:=Worksheets("dB").Range("P12"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With UserForm1
.ComboBox12.RowSource = "dB!P11:dB!P" & FinListingFournisseur
.ComboBox14.RowSource = "dB!P12:dB!P" & FinListingFournisseur
End With
End If
If FinListingCouleur = 11 Then
With UserForm1
.ComboBox18.RowSource = ""
.ComboBox13.RowSource = "dB!Q11:dB!Q11"
End With
ElseIf FinListingCouleur > 11 Then
Worksheets("dB").Range("Q12:Q" & FinListingCouleur).Sort Key1:=Worksheets("dB").Range("Q12"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With UserForm1
.ComboBox13.RowSource = "dB!Q11:dB!Q" & FinListingCouleur
.ComboBox18.RowSource = "dB!Q12:dB!Q" & FinListingCouleur
End With
End If
If FinListingFermeture <= 11 Then
UserForm1.ComboBox19.RowSource = ""
ElseIf FinListingFermeture > 11 Then
Worksheets("dB").Range("R11:R" & FinListingFermeture).Sort Key1:=Worksheets("dB").Range("R11"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
UserForm1.ComboBox19.RowSource = "dB!R11:dB!R" & FinListingFermeture
End If
If FinListingClient > 2 Then
With UserForm1
.ComboBox1.RowSource = "Client!A3:Client!B" & FinListingClient
.ComboBox20.RowSource = "Client!A3:Client!B" & FinListingClient
End With
Else
With UserForm1
.ComboBox1.RowSource = ""
.ComboBox20.RowSource = ""
End With
End If
End Sub
 
Re : Problème de tri

Bonsoir,

Je n'ai pas repris ta macro car il n'y a pas de fichier associé... Mais j'ai fait un test avec des données accolées et un code similaire au tien trie bien les colonnes indépendamment les unes des autres...

Cordialement
 
- 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

  • Question Question
XL 2021 listbox
Réponses
18
Affichages
293
Réponses
5
Affichages
270
Réponses
14
Affichages
252
Réponses
4
Affichages
201
Réponses
17
Affichages
1 K
Réponses
5
Affichages
545
Réponses
7
Affichages
168
Retour