1

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

braX
  • 11,506
  • 5
  • 20
  • 33
VBAbyMBA
  • 806
  • 2
  • 12
  • 30

1 Answers1

0

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.

  • 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?? – VBAbyMBA May 25 '20 at 05:02
  • In that case you will have to use a class module to create a control array...coz I can think of no other way to do this in vba than a creating a class – Amrit Singh May 25 '20 at 05:47
  • Dos this use existing textboxes in the UserForm and assigning a same set of event procedures?? or I need to Create dynamic Userform – VBAbyMBA May 25 '20 at 06:19