Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default combobox question

I'm new to comboboxes and need a few clues.

I have Combobox1 that lists 3 dates. Combobox2 lists the names of
volunteers.

I want to be able to make many selections from combobox2 to produce a LIST
of volunteers (not just change the value of 1 cell). If the 1st, 2nd or 3rd
date is selected, the list of volunteers should be in columns start ing in
C5, E5 or G5 respectively.

Could one of you gurus point me in the right direction?

Thanks in advance
Giselle



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default combobox question

Giselle,
You need a ListBox to do multiselection. The following code is
a starter for you. You need to change worksheets etc as needed. I have
assumed there will be a command button (CommandButton1_Click) to initiate the
posting of data to the spreadsheet.



Public dteIndex As Integer

Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
dteIndex = ComboBox1.ListIndex ' <=== Save index of combobox (0,1 or 2)
ComboBox1.Value = Format(ComboBox1.Value, "dd-mmm-yyyy") ' <== Format date
(change as required)
End Sub

Private Sub CommandButton1_Click()

If dteIndex = -1 Then ' <=== no date selected
MsgBox "Please select a date"
Exit Sub
End If

Col = dteIndex * 2 + 3 ' <=== Column C , E or G
Row = 4
Worksheets("sheet2").Select ' output on Sheet2 Change to suit your needs
With Worksheets("sheet2") ' <=== Change to suit your needs
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then ' <=== name selected
Row = Row + 1
.Cells(Row, Col) = ListBox1.List(i)
End If
Next
End With
End Sub

Private Sub UserForm_Initialize()
Worksheets("sheet1").Select
With Worksheets("sheet1")
For i = 1 To 3
ComboBox1.AddItem .Cells(i, 2) '<=== Dates in column B
Next i
For i = 1 To 5
ListBox1.AddItem .Cells(i, 1) '<=== Names in column A
Next
End With
ListBox1.MultiSelect = 1 ' <=== allow mlutiple selections
End Sub

HTH

"Giselle" wrote:

I'm new to comboboxes and need a few clues.

I have Combobox1 that lists 3 dates. Combobox2 lists the names of
volunteers.

I want to be able to make many selections from combobox2 to produce a LIST
of volunteers (not just change the value of 1 cell). If the 1st, 2nd or 3rd
date is selected, the list of volunteers should be in columns start ing in
C5, E5 or G5 respectively.

Could one of you gurus point me in the right direction?

Thanks in advance
Giselle




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
another combobox question teepee Excel Discussion (Misc queries) 2 May 13th 07 01:01 AM
another combobox question Gary Keramidas Excel Programming 3 December 2nd 05 12:59 AM
Combobox Question Andy Excel Programming 2 July 26th 05 04:52 PM
Combobox Question scrabtree[_2_] Excel Programming 1 October 7th 04 07:48 PM
ComboBox Question Kevin Excel Programming 1 December 7th 03 04:54 PM


All times are GMT +1. The time now is 11:41 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"