Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim c, plage As Range, filtre As Range, lig&, col%, r As Range
c = Target.Offset(, 2) 'compétence
If Intersect(Target, [N:N]) Is Nothing Or c = "" Then Exit Sub
Cancel = True
Application.ScreenUpdating = False
'---filtre élaboré (avancé)---
[A5].Formula = "=OR(P5<>" & c & ",AND(Q5=0,LEFT(R5)<>""-""))" 'critères
Set plage = Rows("4:" & [B65536].End(xlUp).Row)
plage.AdvancedFilter xlFilterInPlace, [A4:A5]
Set filtre = plage.Offset(1).SpecialCells(xlCellTypeVisible)
plage.AdvancedFilter xlFilterInPlace, "" 'désactivation du filtre
On Error Resume Next 'sécurité
Application.EnableEvents = False
'---1er masquage : des lignes filtrées---
filtre.EntireRow.Hidden = True
'---2ème masquage : des colonnes où Target n'est pas absent---
lig = Target.Row
col = [IV4].End(xlToLeft).Column 'n° dernière colonne
For col = 22 To col 'à partir de la colonne V
If Cells(lig, col) = "" Then Columns(col).Hidden = True
Next
'---3ème masquage : des lignes si pas d'absence affichée---
For Each r In Intersect(plage.Offset(1), Columns("V:IV")).Rows
If r.EntireRow.Hidden = False Then
If Application.CountA(r.SpecialCells(xlCellTypeVisible)) = 0 _
Then r.EntireRow.Hidden = True
End If
Next
Application.EnableEvents = True
End Sub