Hi all,

I have a userform that has textboxes that are created and populated dynamically at runtime.

i.e.: based on the number of cells found to be populated with data on a spreadsheet, I create a userform with textboxes with values cooresponding to those cells

I want to add the ability to double click on these textboxes and have the value changed to the current date being displayed by a calander control that is also built into my userform.

But since don't know how many textboxes are going to be created on a given execution of the code, I can't just make the subs that would normally control click actions.

Say there were 2 textboxes being created, I'd then need:

Sub Textbox1_dblclick(ByVal Cancel as MSForms.ReturnBoolean)
Textbox1 = calendar1
End sub
-----------------------------------
Sub Textbox2_dblclick(ByVal Cancel as MSForms.ReturnBoolean)
Textbox2 = calendar1
End sub

But if I have 5 textboxes, I'd need 5 subs. If 10, then 10. etc.

Is there any way to include a variable as part of a sub's name?

Like say:

Sub Controls("Textbox" & N)_dblClick(ByVal Cancel As MSForms.ReturnBoolean)

with the value for N being passed by another procedure during the intial building of the userform?