Please don\'t consider this question as a repeated question! This question is clearly different from earlier similar-looking queries.
Can you try this. A bit rushed, so wouldn't be surprised if something goes wrong, but will come back tomorrow if so.
Behind the form
Private col As Collection
Private Sub UserForm_AddControl(ByVal Control As MSForms.Control)
Dim cl As Class2
Dim ctl As MSForms.CommandButton
Set col = New Collection
For Each ctl In Me.Controls
Set cl = New Class2
Set cl.btEvents = ctl
col.Add cl
Next ctl
End Sub
Private Sub UserForm_Initialize()
Dim btEx As MSForms.CommandButton
Set btEx = UserForm1.Controls.Add("Forms.CommandButton.1")
With btEx
.Top = 12
.Left = 12
.Width = 72
.Height = 36
.Caption = "Click Me"
End With
End Sub
Class module The only change here is to add some spacing so the buttons don't appear on top of each other.
Public WithEvents btEvents As MSForms.CommandButton
Private Sub btEvents_click()
Dim btEx As MSForms.CommandButton
Set btEx = UserForm1.Controls.Add("Forms.CommandButton.1")
With btEx
.Top = 30 * UserForm1.Controls.Count
.Left = 30
.Width = 72
.Height = 36
.Caption = "Click Me"
End With
End Sub