cgannm
12-18-2008, 10:37 AM
Hi, can you help modify code to add ListBox selections in range B5:B15 only.
Also, I would like for ListBox to append a new selection within this range. This code puts new selections starting in B5 and overwrites selections already made.
Thanks,
cgannm
Private Sub CommandButton2_Click()
Dim lItem As Long
Dim cell As Range
Set cell = ActiveSheet.Range("B5")
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
Also, I would like for ListBox to append a new selection within this range. This code puts new selections starting in B5 and overwrites selections already made.
Thanks,
cgannm
Private Sub CommandButton2_Click()
Dim lItem As Long
Dim cell As Range
Set cell = ActiveSheet.Range("B5")
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