PDA

View Full Version : Solved: Place Mult Select Listbox selections in specified cells



cgannm
09-18-2007, 09:00 AM
I am attempting to modifiy this borrowed code which creates a multi-select dropdown listbox. The name selections are dynamically linked to another sheet, when selections are made they are put at the end of the column F.

What i am having difficulty with is changing where the selections are made. I want the selections to be placed in cells $F$3 thru $F$9, instead of at the end.

The dropdown list contains names. These names would placed in the excel form to show operators present for shift rotation.

Please advise.

Thanks,
Anna
~~~~~~~~~~~~~~~~~~~~~


Private Sub CheckBox1_Click()
Dim lItem As Long
For lItem = 0 To ListBox1.ListCount - 1
ListBox1.Selected(lItem) = CheckBox1
Next
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
Dim lItem As Long
For lItem = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(lItem) = True Then
'ActiveSheet.Range("A65536").End(xlUp)(2, 1) = ListBox1.List(lItem)
ActiveSheet.Range("F65536").End(xlUp)(2, 1) = ListBox1.List(lItem)
ListBox1.Selected(lItem) = False
End If
Next
End Sub
Private Sub ListBox1_Click()
End Sub

Private Sub UserForm_Click()
End Sub

**Module for button
Sub showit()
UserForm1.Show
End Sub

Bob Phillips
09-18-2007, 09:59 AM
Private Sub CommandButton2_Click()
Dim lItem As Long
Dim cell As Range
Set cell = ActiveSheet.Range("F3")
For lItem = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(lItem) = True Then
cell.Value = ListBox1.List(lItem)
Set cell = cell.Offset(1, 0)
ListBox1.Selected(lItem) = False
End If
Next
End Sub

cgannm
09-19-2007, 06:27 AM
Solved. Thanks!This works perfectly.




-Anna-