I am trying to create the code for the command button created at runtime. The command button created based on the dynamic input. I found the solution here
Assign code to a button created dynamically
The problem is this code is used for one command button only, I have several command button created at runtime. This is my code.
For i = 1 To RevCounter
Set ctlTXT = Me.Controls.Add("Forms.CommandButton.1")
ctlTXT.name = "Rev" & i
ctlTXT.Caption = Sheet4.Range("D" & i + 5).value
ctlTXT.Left = 18
ctlTXT.Height = 18: ctlTXT.Width = 72
ctlTXT.Top = 15 + ((i - 1) * 25)
Next
The question is, how to assign the code for command button created at runtime. For example if RevCount=5, there will be 5 command buttons created at runtime. I need to assign the code for each of the command buttons created.