Re : Incorporer une condition dans une macro
Une macro pour démarrer...
J'ai choisi d'utiliser la fonction recherche (fin, ctrl F) d'Excel pour trouver le premier qui n'a que cinq matches. C'est plus rapide, surtout si le nombre de joueurs est important
La première colonne contient les noms, la seconde les matches et la troisième des performances...
Sub tri_super_cinq()
Range("A1").Select
Selection.CurrentRegion.Select
Set base = Selection
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Add Key:=Range("B2") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Feuil1").Sort
.SetRange base
.Header = xlYes
.Orientation = xlTopToBottom
.Apply
End With
'recherche de la zone de + 5
Columns("B:B").Select
Selection.Find(What:="5", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
Set base = Range("A1:C" & ActiveCell.Row)
base.Select
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Feuil1").Sort.SortFields.Add Key:=Range("C2") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Feuil1").Sort
.SetRange base
.Header = xlYes
.Orientation = xlTopToBottom
.Apply
End With
End Sub
Voir la pièce jointe.
Bon courage
Hellnar