3

I am adding several CommandButtons dynamically to my user form. To assign code, I used the answer of this question: Assign code to a button created dynamically

However, I need to determine which button has been clicked. They all do have different names. Therefore, my initial idea was to get the name of the clicked button in the CmdEvents_Click() procedure. However, I have not found a solution how to do that.

Does anyone have a solution how to trigger button specific events?

Community
  • 1
  • 1
timbmg
  • 3,192
  • 7
  • 34
  • 52
  • 1
    It should be possible. Add the Name of the new command e.g. like```ctl_Command.Name = "name_" & i``` and then in the ```CmdEvents_Click``` just use ```CmdEvents.Name```. – Daniel Dušek Dec 02 '15 at 14:28
  • if you add this as an answer, I'll give you a green checkmark :) – timbmg Dec 02 '15 at 14:30

1 Answers1

2
  • Add the Name of the new command e.g. like ctl_Command.Name = "name_" & i
  • Then in the CmdEvents_Click just use CmdEvents.Name.
Daniel Dušek
  • 13,683
  • 5
  • 36
  • 51