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
blckbird
  • 3,030
  • 6
  • 28
  • 50

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,316
  • 5
  • 34
  • 50