Bonjour à tous,
Autres façons de coder :
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i%
If Not Application.Intersect(Target, Range("a2")) Is Nothing Then
Application.ScreenUpdating = False
Range("b:bc").EntireColumn.Hidden = False 'affiche tout
Select Case Target
Case Is = 2: i = 32 'af (i= N°colonne)
Case Is = 3: i = 36
Case Is = 4: i = 40
Case Is = 5: i = 44
Case Is = 6: i = 48
Case Is = 7: i = 52 'az
Case Is = 8: Exit Sub
Case Else: Exit Sub
End Select
Range(Cells(1, i), Cells(1, 55)).EntireColumn.Hidden = True
End If
End Sub
ou encore
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i%
If Not Application.Intersect(Target, Range("a2")) Is Nothing Then
Application.ScreenUpdating = False
Range("b:bc").EntireColumn.Hidden = False 'affiche tout
If Target = "" Or Target > 7 Then Exit Sub
i = Target * 4 + 24
Range(Cells(1, i), Cells(1, 55)).EntireColumn.Hidden = True
End If
End Sub
Amicalement
Claude