Sub GrouperColonnes_sur_condition()
'NB: A ne lancer qu'une seule fois
Flag = False
For j = 1 To 24
If Cells(1, j).Value <> "2" Then
Flag = True: cVisible = cVisible + 1
Else
Flag = False
End If
If Flag = False And cVisible <> 0 Then
Range(Cells(1, j - cVisible), Cells(1, j - 1)).EntireColumn.Group
cVisible = 0
ElseIf Flag = True And cVisible <> 0 And j = 24 Then
Range(Cells(1, j - cVisible + 1), Cells(1, j - 1 + 1)).EntireColumn.Group
Else
End If
Next j
ActiveSheet.Outline.ShowLevels 0, 1
'inspiré par un code glané sur le web anglophone.
End Sub