Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Multiselect with Combo / List boxes

I am trying to use a combo or list box that uses "rowsource" to populate the
control with selections. I then want the user to be able to select one or
numerouse values and these values must be 'written' to either a cell in the
workbook or a variable.

I cannot seem to get the control to 'write' the selected values.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Multiselect with Combo / List boxes


Try

Code:
--------------------

Private Sub CommandButton1_Click()
Dim lSelected As Long
Dim sSelected As String

For lSelected = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(lSelected) = True Then
If sSelected = Empty Then
sSelected = ListBox1.List(lSelected)
Else: sSelected = sSelected & ListBox1.List(lSelected)
End If
'this line will write to consecutive cells in sheet 2
' Sheet2.Cells(Rows.Count).End(xlUp).Offset(1, 0) = ListBox1.List(lSelected)
ListBox1.Selected(lSelected) = False
End If
Next
MsgBox sSelected
End Sub

--------------------


--
royUK

Hope that helps.

RoyUK
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=24881

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Multiselect with Combo / List boxes

It's the Control Source property.

HTH. Best wishes Harald

"Les G" wrote in message
...
I am trying to use a combo or list box that uses "rowsource" to populate
the
control with selections. I then want the user to be able to select one or
numerouse values and these values must be 'written' to either a cell in
the
workbook or a variable.

I cannot seem to get the control to 'write' the selected values.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Multiselect with Combo / List boxes

Oops, missed the "or numerouse". This needs coding, sorry.

"Harald Staff" wrote in message
...
It's the Control Source property.

HTH. Best wishes Harald

"Les G" wrote in message
...
I am trying to use a combo or list box that uses "rowsource" to populate
the
control with selections. I then want the user to be able to select one or
numerouse values and these values must be 'written' to either a cell in
the
workbook or a variable.

I cannot seem to get the control to 'write' the selected values.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Multiselect with Combo / List boxes

Hey Roy... Thanks you are a star. I will work on this, as it consistently
writes to the last column, but I will get it right from now. If I have a
problem I will come back to

"royUK" wrote:


Try

Code:
--------------------

Private Sub CommandButton1_Click()
Dim lSelected As Long
Dim sSelected As String

For lSelected = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(lSelected) = True Then
If sSelected = Empty Then
sSelected = ListBox1.List(lSelected)
Else: sSelected = sSelected & ListBox1.List(lSelected)
End If
'this line will write to consecutive cells in sheet 2
' Sheet2.Cells(Rows.Count).End(xlUp).Offset(1, 0) = ListBox1.List(lSelected)
ListBox1.Selected(lSelected) = False
End If
Next
MsgBox sSelected
End Sub

--------------------


--
royUK

Hope that helps.

RoyUK
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=24881


Reply
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
Selecting subsets using combo boxes or list boxes CLamar Excel Discussion (Misc queries) 0 June 1st 06 07:43 PM
Questions on combo boxes and list boxes. Marc New Users to Excel 1 March 14th 06 09:40 AM
Combo/List Boxes Fordy New Users to Excel 2 March 9th 06 10:07 AM
Filtered list for Combo Box ListFillRange - Nested Combo Boxes DoctorG Excel Programming 3 February 23rd 06 12:15 PM
List boxes/combo boxes Tibow Excel Programming 3 February 17th 04 12:35 PM


All times are GMT +1. The time now is 09:14 PM.

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

About Us

"It's about Microsoft Excel"