Private Sub ComboBox1_Change()
Static flag As Boolean
If flag Then Exit Sub
Dim i%, col%, col3%, P As Range, cb$, test As Boolean
i = ComboBox1.ListIndex
If i = -1 Then Exit Sub
flag = True
If i < 3 Then col = Application.Match("Cahier " & i + 1, Rows(1), 0) Else col = Application.Match("Cahier 1", Rows(1), 0)
col3 = Application.Match("Cahier 3", Rows(1), 0)
Set P = IIf(i < 3, Cells(1, col).MergeArea, Range(Cells(1, col), Cells(1, col3).MergeArea))
cb = ComboBox1
With [Cahiers]
With .Cells(i + 1)
test = .Value Like "Masquer*"
.Replace IIf(test, "Masquer", "Afficher"), IIf(test, "Afficher", "Masquer"), xlPart 'modifie la liste source
End With
If cb = "Masquer tous" Then .Replace "Masquer", "Afficher" Else If cb = "Afficher tous" Then .Replace "Afficher", "Masquer"
If Application.CountIf(.Cells, "Afficher Cahier*") = 3 Then .Cells(4) = "Afficher tous"
If Application.CountIf(.Cells, "Masquer Cahier*") = 3 Then .Cells(4) = "Masquer tous"
End With
ComboBox1 = cb 'restitue la valeur choisie
P.EntireColumn.Hidden = test 'masque/affiche
flag = False
End Sub