View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Program a combobox/dropdownlist to create

Instead of adding them, you could just design them in and hide them. Then after
you get the value from the user, just unhide the ones you want.

Option Explicit
Private Sub ComboBox1_Change()
Dim iCtr As Long
For iCtr = 1 To 10
Me.Controls("textbox" & iCtr).Visible _
= CBool(iCtr <= CLng(Me.ComboBox1.Value))
Next iCtr
End Sub
Private Sub UserForm_Initialize()
Dim iCtr As Long
For iCtr = 1 To 10
Me.Controls("textbox" & iCtr).Visible = False
Me.ComboBox1.AddItem iCtr
Next iCtr
End Sub

I put 10 textboxes in the userform. They were named textbox1 thru textbox10--so
the code would work.


wrote:

Sorry, I left out pertinent information.

I want these controls created on a user form as form
controls.

Thanks
Ed

-----Original Message-----
Where are these located?

Where do you want them created?

ActiveX controls or Forms controls?

--
Regards,
Tom Ogilvy

ed wrote in message
...
Hi all,

I want to Program a combobox/dropdownlist to create
textboxes dynamically.

A user simply selects a number from a combobox, say

from 1-
10 and this creates a corresponding number of label and
textboxes.

Thanks
Edward


.




.


--

Dave Peterson