#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default List boxes

Hi,
I have an option button on a worksheet that activates a
list box when the user clicks it. I ask the user to select
up to 15 items in the list box. I would like to take the
user's selections from the list box and store them in a
column on another worksheet in the workbook. Does anyone
have any idea/code that I could use to accomplish this
task?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default List boxes

There are a few methods for doing this, but the following code is
probably the simplest (not tested):

Sub PrintSelection()
Dim i As Integer, iCount As Integer

For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
iCount = iCount + 1
Cells(iCount, 1) = ListBox1.List(i)
End If
Next i

End Sub


HTH
Simon Livings

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default List boxes

Simon,
I have added the code you sent me to the Private Sub
ListBox_Hosp_Click() portion of my list box, but when I make my
selections, the selections do not appear anywhere on my worksheet?
Here is what I have:
'Private Sub ListBox_Hosp_Click()
Sub PrintSelection()
Dim i As Integer, iCount As Integer

For i = 0 To ListBox_Hosp.ListCount - 1
If ListBox_Hosp.Selected(i) Then
iCount = iCount + 1
Cells(iCount, 1) = ListBox_Hosp.list(i)
End If
Next i

End Sub
'End Sub

Any thoughts?
Joe



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default List boxes

Hi Joe,

I tried Simon's code in the ListBox DblClick event , and it functioned, as
intended, entering the selected values in cells A1 downwards.

---
Regards,
Norman


"Joe Powers" wrote in message
...
Simon,
I have added the code you sent me to the Private Sub
ListBox_Hosp_Click() portion of my list box, but when I make my
selections, the selections do not appear anywhere on my worksheet?
Here is what I have:
'Private Sub ListBox_Hosp_Click()
Sub PrintSelection()
Dim i As Integer, iCount As Integer

For i = 0 To ListBox_Hosp.ListCount - 1
If ListBox_Hosp.Selected(i) Then
iCount = iCount + 1
Cells(iCount, 1) = ListBox_Hosp.list(i)
End If
Next i

End Sub
'End Sub

Any thoughts?
Joe



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default List boxes

Norman,
You are correct, I changed the event on my list box to DblClick and the
code Simon sent does work. One more question. I only want the user to
select up to 15 data points from my list box, is there a way to modify
Simon's code to accomplish this?
TIA
Joe



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


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
List boxes Denise Excel Programming 1 June 8th 04 06:35 PM
List Boxes Neil Excel Programming 0 May 25th 04 11:19 AM
List boxes/combo boxes Tibow Excel Programming 3 February 17th 04 12:35 PM


All times are GMT +1. The time now is 07:04 PM.

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"