LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Data Val MultiSelect on Userform?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Val MultiSelect ? TotallyConfused Excel Programming 1 September 29th 09 05:59 PM
userform multiselect listbox problem apndas[_7_] Excel Programming 4 July 25th 06 04:12 AM
Activating userform and filling it with data form row where userform is activate Marthijn Beusekom via OfficeKB.com[_2_] Excel Programming 3 May 6th 05 05:44 PM
List Box - MultiSelect Bill[_28_] Excel Programming 2 January 31st 05 10:31 PM
MultiSelect ListBox StephanieH Excel Programming 5 November 20th 04 12:29 AM


All times are GMT +1. The time now is 09:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"