Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Me.[A3:G3]) Is Nothing Then
' Désactiver les mises à jour d'écran pour améliorer la performance
Application.ScreenUpdating = False
' Effacer les filtres éventuels
Me.AutoFilterMode = False
rmax = Me.Cells(Me.Rows.Count, 1).End(xlUp).Row
Set zone = Range("A3:G" & rmax)
Set clés = Range("C4:C" & rmax)
With Me.Sort
Select Case True ' on récupère le sens de tri
Case .Rng.Address <> zone.Address
Case .SortFields(1).Key.Address <> clés.Address
Case Else: SensTri = .SortFields(1).Order
End Select
.SortFields.Clear
.SortFields.Add2 Key:=clés, _
SortOn:=xlSortOnValues, DataOption:=xlSortNormal, _
Order:=IIf(SensTri = xlAscending, xlDescending, xlAscending)
.SetRange zone
.Header = xlYes: .MatchCase = False
.Orientation = xlTopToBottom: .SortMethod = xlPinYin
.Apply
End With
' Réactiver la mise à jour de l'écran
Application.ScreenUpdating = True
Cancel = True
End If
End Sub