Adding SINGLE button
Private Sub CommandButton1_Click()
ActiveSheet.Buttons.Delete
Dim b As Button
l = 200
t = 100
w = 100
h = 55
Set b = Buttons.Add(l, t, w, h)
b.Caption = "i m button"
MsgBox "Button Created"
End Sub
Creation of Multiple Buttons through Loop
Private Sub CommandButton1_Click()
ActiveSheet.Buttons.Delete
Dim b As Button
l = 300 ' left
t = 100 'top
w = 100 'Width
h = 55 'Height
For i = 1 To 5
Set b = Buttons.Add(l, t, w, h)
b.Caption = "Button" & i
MsgBox "Button " & i & " has been Created"
t = t + 100
Next
End Sub
Creation & Adjust buttons in cells through Loop
Private Sub CommandButton1_Click()
ActiveSheet.Buttons.Delete
Columns("g").ColumnWidth = 25
Application.ScreenUpdating = False
Dim b As Button
n = 3
Dim r As Range
For i = 1 To 5
Set r = Range("G" & n)
Set b = ActiveSheet.Buttons.Add(r.Left, r.Top, r.Width, r.Height)
b.Caption = "button" & i
MsgBox "button " & i & " has been created"
n = n + 2
Next
Application.ScreenUpdating = True
End Sub