Private Sub btn_addprsn()
...
Call AddBtnAdd
...
End Sub
Private Sub AddBtnAdd()
Dim nbPersonnes As Integer
Dim numLigne As Integer
numLigne = Range("BC4") - 1
nbPersonnes = Range("BC3")
With ActiveSheet
LargeurBouton = Columns(3).Width
GaucheBouton = Columns(3).Left
HauteurBouton = Rows(numLigne).Height
SommetBouton = Rows(numLigne).Top
End With
Set oOLE = ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", _
Left:=GaucheBouton, Top:=SommetBouton, Width:=LargeurBouton, Height:=HauteurBouton)
oOLE.Name = "btnAddLigne_" & nbPersonnes
oOLE.Object.Caption = "+"
Code = "Sub btnAddLigne_" & nbPersonnes & "_Click()" & vbCrLf
Code = Code & "AddLigne(" & nbPersonnes & ")" & vbCrLf
Code = Code & "End Sub"
With ActiveWorkbook.VBProject.VBComponents(ActiveSheet.CodeName).CodeModule
NextLine = .CountOfLines + 1
.insertLines NextLine, Code
End With
End Sub