have the following code in my user form which uses a class module (not shown). It all works great, but I want to add the buttons dynamically according to a list in my worksheet and don't know how to use an array to dimension them. At the top of my user form I Dim the events references:
Dim cbe1 As CCommandButtonEvents
Dim cbe2 As CCommandButtonEvents
Dim cbe3 As CCommandButtonEvents
Then again in the user from code I Dim cb1 - 3 and also set cbe1 and in the following line call code in the class module which also needs to be from an array I think.
Private Sub UserForm_Initialize()
Dim cb1 As MSForms.CommandButton
Set cb1 = Me.Controls.Add("Forms.CommandButton.1", "CommandButton1", True)
cb1.Caption = "First button"
cb1.Top = 20
cb1.Left = 20
Set cbe1 = New CCommandButtonEvents
cbe1.SetUpCommandButton cb1, Me
End Sub
Can anyone help me figure out how to so this as it is beyond my knowledge base and quite frustrating as I have it all working great non dynamically.
Dim cbe1 As CCommandButtonEvents
Dim cbe2 As CCommandButtonEvents
Dim cbe3 As CCommandButtonEvents
Then again in the user from code I Dim cb1 - 3 and also set cbe1 and in the following line call code in the class module which also needs to be from an array I think.
Private Sub UserForm_Initialize()
Dim cb1 As MSForms.CommandButton
Set cb1 = Me.Controls.Add("Forms.CommandButton.1", "CommandButton1", True)
cb1.Caption = "First button"
cb1.Top = 20
cb1.Left = 20
Set cbe1 = New CCommandButtonEvents
cbe1.SetUpCommandButton cb1, Me
End Sub
Can anyone help me figure out how to so this as it is beyond my knowledge base and quite frustrating as I have it all working great non dynamically.