Dim n, cible As Range 'mémorise les variables
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
n = Int(Val(CStr(Target(1))))
If n < 1 Then Application.OnUndo "", "": Exit Sub
Cancel = True
Target(2, 1).Resize(n).Insert xlDown
Target(2, 1).Resize(n).Interior.ColorIndex = 35 'vert clair
Set cible = Target
Application.OnUndo "J'annule", Me.CodeName & ".Z"
End Sub
Sub Z()
If n < 1 Or cible Is Nothing Then Exit Sub
cible(2, 1).Resize(n).Delete xlUp
Application.OnRepeat "", Me.CodeName & ".Y"
End Sub
Sub Y()
If Not cible Is Nothing Then Worksheet_BeforeDoubleClick cible, False
End Sub