Creating an array of Command Buttons

515 Views Asked by At

I am in a situation Where I need to Create multiple Command buttons and assign a single event handler to these buttons using following Event Handler.

Private Sub Digits_Click(Index as Integer)
Display.Caption=Display.Caption+Digits(Index).Caption
End Sub

I created first button and copy paste it to the userform but it did not Prompt:

"You already have a control Name XXX. Do you want to create a control array?"

VBA doesn’t allow us to to create Control Array like in VB6 and VB.Net. My Question is Can we still create Control Array in VBA?? I am new to this Topic Please help

1

There are 1 best solutions below

3
On

You might want to look at creating a loop and dynamically adding the command buttons

Every cmd should have a unique name.. It can call the same sub procedure. But every button should be unique in its own sense.