Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$B$1" Then
'calcul du nombre de ligne déjà présentes
Set c = Range("A:A").Find("TOTAL")
If Not c Is Nothing Then
nblignes = c.Row - 2 - 2
End If
If Range("B1") > 15 And ((nblignes = 15) Or nblignes < Range("B1")) Then
'ajout de lignes B1-nblignes)
nbmanquantes = Range("B1") - nblignes
MsgBox ("manque" & nbmanquantes & " lignes")
Rows(nblignes + 2 & ":" & nblignes + 1 + nbmanquantes).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End If
If Range("B1") <= 15 And nblignes > 15 Then
MsgBox ("trop de lignes")
End If
End If
End Sub