Re : Petit problème insertion/supression ligne VBA
bonjour Cotcot
une proposition pour bouton +
Private Sub CommandButton1_Click()
Dim L1 As Integer, L2 As Integer
Dim Message, Title, Default, MyValue
Dim VarReponse As String, Cel As Range
VarReponse = MsgBox("Insérerer une ligne?", vbYesNo, "Alerte")
If VarReponse = vbNo Then Exit Sub
For Each Cel In Range("B7:B" & Range("B1000").End(xlUp).Row)
If Cel = "Total famille" Then L1 = Cel.Row: Exit For
Next Cel
For Each Cel In Range("B7:B" & Range("B1000").End(xlUp).Row)
If Cel.Row > L1 And Cel = "Total famille" Then L2 = Cel.Row: Exit For
Next Cel
' Définit le message.
Message = "Entrez une valeur > " & L1 & " et < " & L2
Title = "Démonstration de InputBox" ' Définit le titre.
Default = "" ' Définition la valeur par défaut.
' Affiche le message, le titre et la valeur par défaut.
x = InputBox(Message, Title, Default)
If x > L1 Or x < L2 Then
Range("A" & x & ":C" & x).Insert Shift:=xlDown
Range("A" & x & ":B" & x).Interior.ColorIndex = Range("A" & x & ":B" & x).Offset(1, 0).Interior.ColorIndex
End If
End Sub
à bientôt