Problème code tri

Jean-luc1311

XLDnaute Occasionnel
Bonjour à tous,

Voila un code que j'utilise dans un tableau pour les colonnes A à G et cela fonctionne.
Que faudrait-il changer pour faire la même chose sur les colonnes H à J sans toucher l'ordre des lignes des colonnes A à G?
J'avoue que je patauge pas mal pour adapter cela.
Cordialement.
PHP:
  Dl = .Range("A65000").End(xlUp).Row + 1
  .Cells(Dl, 1) = ComboBox1
  .Cells(Dl, 2) = ComboBox2
  .Cells(Dl, 3) = ComboBox3
  .Cells(Dl, 4) = ComboBox4
  .Cells(Dl, 5) = ComboBox5
  .Cells(Dl, 6) = CDbl(ComboBox6)
  .Cells(Dl, 7) = ComboBox7
  
With .Range("A4:G" & Dl)
    .Sort Key1:=.Range("A4"), Order1:=xlAscending, Header:=xlGuess, _
         OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
         .HorizontalAlignment = xlLeft
End With
End With
End If
End Sub

JL
 

Papou-net

XLDnaute Barbatruc
Re : Problème code tri

Bonjour Jean-Luc, phlaurent55,

Jean-Luc, la proposition de phlaurent fonctionne, sauf qu'il ne faut pas modifier "A4" dans le deuxième tri :

Code:
Dl = .Range("A65000").End(xlUp).Row + 1
With .Range("A4:G" & Dl)
    .Sort Key1:=.Range("A4"), Order1:=xlAscending, Header:=xlGuess, _
         OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
         .HorizontalAlignment = xlLeft
End With
End Sub
...
...
Dl = .Range("[COLOR="Red"]H65000[/COLOR]").End(xlUp).Row + 1
With .Range("[COLOR="Red"]H4:J[/COLOR]" & Dl)
    .Sort Key1:=.Range("[COLOR="Red"]A4[/COLOR]"), Order1:=xlAscending, Header:=xlGuess, _
         OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
         .HorizontalAlignment = xlLeft
End With
End Sub

Espérant avoir répondu.

Cordialement.
 

Discussions similaires

Statistiques des forums

Discussions
312 471
Messages
2 088 703
Membres
103 927
dernier inscrit
Mkeal