Hi,
I am adding commandbuttons and other controls at runtime to a userform in Excel. Once added the buttons do not work based on the subroutine that should catch the event. Example below:
Sub PushButton_click()
Beep
End Sub
Private Sub UserForm_Click()
Beep
End Sub
Private Sub UserForm_activate()
Set myButton = Me.Controls.Add("Forms.CommandButton.1")
With myButton
.Left = 5
.Top = 65
.Height = 20
.Width = 50
.Name = "PushButton"
.Caption = "Store Map"
Debug.Print .Name
End With
End Sub
Clicking the form makes it beep but not the button. What am I missing?
TIA
I am adding commandbuttons and other controls at runtime to a userform in Excel. Once added the buttons do not work based on the subroutine that should catch the event. Example below:
Sub PushButton_click()
Beep
End Sub
Private Sub UserForm_Click()
Beep
End Sub
Private Sub UserForm_activate()
Set myButton = Me.Controls.Add("Forms.CommandButton.1")
With myButton
.Left = 5
.Top = 65
.Height = 20
.Width = 50
.Name = "PushButton"
.Caption = "Store Map"
Debug.Print .Name
End With
End Sub
Clicking the form makes it beep but not the button. What am I missing?
TIA