i can dynamically add commandbuttons to an excel form. And then I use WithEvents.
I just cannot get the Click event to fire. I can see the list of events in the dropdown for my new control that will be added to the control collection but it won't fire.
Any ideas why?
Code:Dim WithEvents cmdAdmit As CommandButton Private Sub UserForm_Click() Set mycmd = Controls.Add("Forms.CommandButton.1", "cmdAdmit", Visible) mycmd.Left = 10 mycmd.Top = 100 mycmd.Width = 175 mycmd.Height = 20 mycmd.Caption = "Admit" End Sub Private Sub cmdAdmit_Click() MsgBox "testing 1-2-3" End Sub




Reply With Quote