1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| Private Sub Worksheet_Change(ByVal Target As Range)
Dim TheCell As Range
'On verifie que le changement a lieu dans le tabeau d'action (TabActions)
If Not Intersect(Target, Feuil1.ListObjects("TabActions").Range) Is Nothing Then
'On regarde si la ligne du tableau impacté par la saisie est intégralement remplie
For Each TheCell In Feuil1.Range("TabActions").Resize(1).Offset(Target.Row - 10)
'Si une cellule n'a pas de contenu, on quitte
If TheCell = "" Then Exit Sub
Next
'Si le code arrive ici, toutes les cellules ont un contenu
'On desactive l'update de l'ecran
Application.ScreenUpdating = False
'On tri donc le tableau par n°Ligne et par date de début
With Feuil1.ListObjects("TabActions").Sort
With .SortFields
.Clear
.Add Key:=Range("TabActions[Poste]"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.Add Key:=Range("TabActions[d et h début]"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
End With
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Application.ScreenUpdating = True
End If
End Sub |
Partager