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 31 32 33 34 35 36 37 38 39 40 41
| Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Application.ScreenUpdating = False
ActiveSheet.Unprotect
Dim pos, cellule, k_1, k_2, k_3, newColClic, modeTri
Static bTriDecroissant As Boolean
Static colClic As Integer
pos = InStr(Target.SubAddress, "!")
If (pos > 0) Then
cellule = Mid(Target.SubAddress, pos + 1, Len(Target.SubAddress) - pos)
k_1 = "A1"
k_2 = "A1"
k_3 = "A1"
newColClic = Asc(Left(cellule, 1)) - 65
If (newColClic = colClic) Then
bTriDecroissant = Not bTriDecroissant
Else
bTriDecroissant = False
End If
colClic = newColClic
If (bTriDecroissant) Then
modeTri = xlDescending
Else
modeTri = xlAscending
End If
If (cellule = "B1") Then
k_1 = "B1": k_2 = "B1": k_3 = "B1"
ElseIf (cellule = "C1") Then
k_1 = "C1": k_2 = "C1": k_3 = "C1"
End If
Range("Plage_1").Sort _
Key1:=Range(k_1), Order1:=modeTri, _
Key2:=Range(k_2), Order2:=modeTri, _
Key3:=Range(k_3), Order3:=modeTri, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
End If
Application.ScreenUpdating = True
Range(k_1).Select
End Sub |
Partager