Probléme avec le classement de la D1 foot

JBARBE

XLDnaute Barbatruc
Bonjour à tous,

La macro suivante ne me tri mal le classement de la D1 de Foot !

Le tri de la cellule DV1 qui lorsqu’elle est sur "Points" ( colonne DH) doit me tenir compte des points mais également de la colonne DO (Différence ) !

peut être que la macro demande à être corrigée !!

Private Sub Worksheet_Change(ByVal Target As Range)
Dim x%, Plg As Range
If Not Application.Intersect(Target, Range("DV1")) Is Nothing Then
Application.ScreenUpdating = False
On Error Resume Next
ActiveSheet.ShowAllData
Set Plg = Range("DG1:DU" & [dg65000].End(xlUp).Row)
x = Application.Match(Target, Rows(1), 0)
On Error GoTo 0
If Target.Count > 1 Or Target = "" Or x = 0 Then Exit Sub

Plg.Sort Key1:=Cells(1, x), Order1:=xlDescending, Key2:= _
Cells(1, "DU"), Order2:=xlDescending, Header:=xlNo, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom

End If
End Sub


La feuille 2 en donne un exemple !

Merci à l'avance et bonne journée !
 

Pièces jointes

  • Foot_Ligue1_Saisons_2016_2017.zip
    161 KB · Affichages: 32

JBARBE

XLDnaute Barbatruc
Bonjour Paf
Qu'elle idiot! Bien sur il fallait prendre le tri dans la colonne DO en non dans DU!
Une petite question : peut-on alléger ma macro report ?

De plus ma macro ignore Toulouse ( voir fichier ) !

Merci!
 

Pièces jointes

  • Foot_Ligue1_Essai1.xlsm
    1.6 MB · Affichages: 46
Dernière édition:

JBARBE

XLDnaute Barbatruc
Bonsoir à tous,

Désolé mais suite à la première journée de D1, mon classement était faux avec Lyon en tête !

Ainsi donc le tri ce fait a partir des points soit la colonne DU qu'il y avait !

Il faudra attendre les autres journées pour avoir le classement parfait!

Ci-joint le fichier D1 2016 - 2017 pour ceux que cela intéresse !

Bonne nuit !
 

Pièces jointes

  • Foot_Ligue1_2016_2017.xlsm
    1.6 MB · Affichages: 45

JBARBE

XLDnaute Barbatruc
Bonjour à tous,

Je reviens sur ce sujet en me disant ( ce que je n'ai pas précisé au début ) si l'on pouvait trier en 1er la colonne DU ( Points) et ensuite la colonne DO (Différence) en ajoutant à ces lignes DU et DO que paf n'a fait qu'avec DO !

Plg.Sort Key1:=Cells(1, x), Order1:=xlDescending, Key2:= _
Cells(1, "DO"), Order2:=xlDescending, Header:=xlNo, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom

Alors le classement dés la 1ere journée serait parfait !!!!

Merci à l'avance et bonne journée !
 

JBARBE

XLDnaute Barbatruc
Bon j'ai trouvé :

Private Sub Worksheet_Change(ByVal Target As Range)
Dim x%, Plg As Range
If Not Application.Intersect(Target, Range("DV1")) Is Nothing Then
Application.ScreenUpdating = False
On Error Resume Next
ActiveSheet.ShowAllData
Set Plg = Range("DG1:DU" & [dg65000].End(xlUp).Row)
x = Application.Match(Target, Rows(1), 0)
On Error GoTo 0
If Target.Count > 1 Or Target = "" Or x = 0 Then Exit Sub

Plg.Sort Key1:=Cells(1, x), Order1:=xlDescending, Key2:= _
Cells(1, "DU"), Order2:=xlDescending, Header:=xlNo, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom

Plg.Sort Key1:=Cells(1, x), Order1:=xlDescending, Key2:= _
Cells(1, "DO"), Order2:=xlDescending, Header:=xlNo, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom

End If
End Sub

Bonne journée !
 

Discussions similaires