Sub
Makro1()
a = 14
For
i = 1
To
3
With
ActiveSheet
Set
Obj = ActiveSheet.OLEObjects.Add(ClassType:=
"Forms.CommandButton.1"
, Left:=220, Top:=a, Height:=30, Width:=120)
.OLEObjects(.OLEObjects.Count).Name =
"S_Btn"
& i
.OLEObjects(
"S_Btn"
& i).
Object
.Caption =
"sta"
With
ThisWorkbook.VBProject.VBComponents(.Name).CodeModule
.InsertLines .CountOfLines + 1,
"Private Sub S_Btn"
& i &
"_Click()"
.InsertLines .CountOfLines + 2,
"MsgBox "
& i
.InsertLines .CountOfLines + 3,
"End Sub"
End
With
End
With
a = a + 43
Next
End
Sub