I have about 200 names in column A which I list in a listbox on a userfrom, which is set to multiselect
I want to be able to select certain names, and copy them to column G. I can do it with single select.
I have about 200 names in column A which I list in a listbox on a userfrom, which is set to multiselect
I want to be able to select certain names, and copy them to column G. I can do it with single select.
![]()
Private Sub CommandButton1_Click() Dim i As Long, n As Long, a() With ListBox1 If .ListIndex = -1 Then Exit Sub ReDim a(1 To .ListCount + 1, 1 To 1) For i = 0 To .ListCount - 1 If .Selected(i) Then n = n + 1 : a(n,1) = .List(.ListIndex) Next Next End With Sheets("YourSheetNameHere").Range("g" & Rows.Count).End(xlUp)(2).Resize(n).Value = a End Sub
Here's a code that will place all the selected items from the listbox and place them in the first empty cell in column G
![]()
Private Sub CommandButton2_Click() Dim lItem As Long For lItem = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(lItem) = True Then Sheet2.Range("G65536").End(xlUp)(2, 1) = ListBox1.List(lItem) ListBox1.Selected(lItem) = False End If Next End Sub
Hi
Thanks Dave, I first saw nothing in column G, but then I noticed, sheet2
thanks it works
Last edited by CobraLAD; 03-13-2008 at 11:56 PM.
Should be working if you change the sheet name to appropreate.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks