View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Transferring items between multicolumn listboxes

You are not using i in yhour code

from:
For i = 0 To .ListCount - 1
If .Selected(i) Then
iIndex = .ListIndex
to:
For i = 0 To .ListCount - 1
If .Selected(i) Then
iIndex = i

" wrote:

Hi-
I've been trying to figure out how to move items between multicolumn
listboxes. I have it all expect for one piece. If I select more than
one item from the source listbox, I don't get all of the selected
items, I only get the first item in the selection repeated a number of
times (that number equalling the number of items I originally
selected).

My code is pasted below. Can anyone steer me in a direction?

Thanks

' Variable declarations
Dim iIndex
Dim iInd2
Dim iSel As Long
Dim i As Long
Dim x As Long

' Checks to see if there is anything selected
' in the listbox to add
If ListBox1.ListIndex = -1 Then GoTo SelectError

' Populates listbox2
With ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
iIndex = .ListIndex
iInd2 = ListBox2.ListCount
ListBox2.AddItem .List(iIndex, 0)
ListBox2.List(iInd2, 1) = .List(iIndex, 1)
ListBox2.List(iInd2, 2) = .List(iIndex, 2)
End If
Next i
End With

Exit Sub

SelectError:
MsgBox "Please make a selection.", vbExclamation + vbOKOnly,
"ERROR"