Private Sub Worksheet_Change(ByVal Cel As Range)
Dim x, Smax As Byte, Plage As Range
If Intersect(Cel, Range("C2")) Is Nothing Or Cel.Cells.Count > 1 Then Exit Sub
Application.EnableEvents = False 'désactive l'action des évènements
On Error Resume Next
If IsError(1 / (Cel >= 1) / (Cel < 13)) Then _
MsgBox "Donnée non valide": Application.Undo: GoTo 2
x = Int(Cel)
Smax = Application.Max(Range("4:4"))
If x = Smax Then GoTo 1
If x > Smax Then
Set Plage = Range(Cells(4, 3 * Smax + 1), Cells(4, 39))
Plage.DataSeries Type:=xlLinear, Step:=1
Plage.EntireColumn.Hidden = False
Else
If MsgBox("Effacer " & Smax - x & " semaines ?", 1) = 2 Then Application.Undo: GoTo 2
Set Plage = Range(Cells(4, 3 * x + 4), Cells(4, 39))
Plage.EntireColumn.Hidden = True
Plage = ""
Range(Plage.Offset(2, 0), Plage.Offset(10000, 0)) _
.SpecialCells(xlCellTypeConstants, 23) = ""
End If
1 Cel = x
2 Application.EnableEvents = True
End Sub