Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
A few days ago I posted to this forum ask if it is possible to create a
list box of different items to be picked and have those items entered into a cell. Saw this in Contextures Website. However, the sample was for an Excel spreadsheet. I asked if it could be done in an Userform. Bernie was kind to answer my post and provided the sample below. However, it is not working I followed to the T and the list of items is not showing in the list box on the Userform. Can someome please help with this. I will need to do this 25 x. What I have on form is 20+ cities and user will need to pick from 10 items on the list box. Same items but for each city it can vary. Therefore I need a textbox to hold the items chose. Would this be the best way to do this or is there some other way that is easier or more efficient. Thank you. On your userform, add a listbox and set its multiselect property to 1- fmMultiSelectMulti, and put the values into it like this using the userform's initital event: Private Sub UserForm_Initialize() Me.ListBox1.List = Worksheets("Sheet1").Range("A1:A10").Value End Sub (Assuming your valid list is in cells A1:A10 of Sheet1) Also add a textbox to your ysefrom for the final string... Add a commandbutton to your userform with code like this: Private Sub CommandButton1_Click() Dim i As Integer Dim myStr As String myStr = "" For i = 0 To Me.ListBox1.ListCount - 1 If Me.ListBox1.Selected(i) Then If myStr = "" Then myStr = Me.ListBox1.List(i) Else myStr = myStr & ", " & Me.ListBox1.List(i) End If End If Next i 'Do something Me.TextBox1.Text = myStr End Sub Then in code load the userform, show it, and have the user select the items from the listbox and click the commandbutton. It will show the selected items in the text box. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Data Val MultiSelect ? | Excel Programming | |||
userform multiselect listbox problem | Excel Programming | |||
Activating userform and filling it with data form row where userform is activate | Excel Programming | |||
List Box - MultiSelect | Excel Programming | |||
MultiSelect ListBox | Excel Programming |