Private Sub Workbook_SheetBeforeDoubleClick(ByVal Feuille As Object, ByVal Cible As Range, Contremander As Boolean)
Dim c&, f&, errNb, Cbl, page_Principale$, Cel As Range
'
page_Principale = "JUILLET 2014" 'À adapter le cas échéant.
'
Cbl = Array([Salarie_n], [Client_n]) 'À adapter selon les besoins :
'Plages de référence aux onglets à afficher/masquer.
'À condition qu'il existe un onglet nommé "JUILLET 2014", on aurait pu écrire :
'
' With Worksheets(page_Principale): Cbl = Array(.Range("$J$2:$R$2"), .Range("$B$3:$B$7"), .Range("$B$10:$B$15")): End With
On Error Resume Next
page_Principale = Worksheets(page_Principale).Name: errNb = Err.Number
On Error GoTo 0
If Feuille.Name = page_Principale Then
For c = UBound(Cbl) To 0 Step -1
If Not Intersect(Cible(1), Cbl(c)) Is Nothing Then Exit For
Next
If c > -1 Then
Contremander = True
On Error Resume Next
Sheets(Cible.Value).Visible = -1
If Err.Number Then
MsgBox "Il n'existe pas d'onglet nommé """ & Cible.Value & """ !"
Else
Sheets(Cible.Value).Activate
End If
On Error GoTo 0
End If
Else
If Not Intersect(Cible, Feuille.[A1]) Is Nothing Then
For c = UBound(Cbl) To 0 Step -1
For f = Cbl(c).Count To 1 Step -1
If Feuille.Name = Cbl(c)(f).Value Then Exit For
Next
If f > 0 Then
Contremander = True
If errNb Then
MsgBox "Il n'existe pas d'onglet """ & page_Principale & """ !"
Else
Worksheets(page_Principale).Activate
Feuille.Visible = 0
End If
Exit For
End If
Next
End If
End If
End Sub