I have two userform listboxes and I want to transfer the selected row from one to the other listbox. Both are two column listboxes set to frmmultiSelectMulti.
I have seen several posts on various other listbox techniques, but not many on transferring from one to another. I also want to remove the transferred items from the first box as they are added to the second box. I get invalid array index when I try running the code below.
Code
Dim iCtr As Long
For iCtr = 0 To lstInitialData.ListCount - 1
If lstInitialData.Selected(iCtr) = True Then
lstFinalData.AddItem
lstFinalData.List(iCtr, 0) = lstInitialData.List(iCtr, 0)
lstFinalData.List(iCtr, 1) = lstInitialData.List(iCtr, 1)
End If
Next iCtr
For iCtr = lstInitialData.ListCount - 1 To 0 Step -1
If lstInitialData.Selected(iCtr) = True Then
'lstInitialData.RemoveItem (iCtr, 0)
'lstInitialData.RemoveItem (iCtr, 1)
End If
Next iCtr
End Sub
Display More