Jump to content

How to add runtime events for command button?


Recommended Posts

Posted

Dear All,

 

How to add runtime events for command button in VBA.

 

 

Dim WithEvents RuntimeCommandButton As CommandButton

 

Private Sub CommandButton1_Click()

 

For i = 0 To 3

Set RuntimeCommandButton = UserForm3.Controls.Add("Forms.CommandButton.1", "RuntimeCommandButton", True)

 

With RuntimeCommandButton

'.Left = RuntimeTextBox.Left + RuntimeTextBox.Width + 10

.top = (i * 20)

.Width = 30

.Height = 15

.Name = (i * 20)

 

End With

Next

 

UserForm3.Show

 

 

End Sub

 

 

Private Sub RuntimeCommandButton_Click()

MsgBox "hai"

End Sub

 

 

This is my code ,Event will work only last added command button in userform3 control.I want to add events for all runtime added command buttons

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...