Alright, here's the situation, I've got a userform that has two listboxes (SendBox and ReceiveBox). What I'm trying to do is list the selected items from SendBox in ReciveBox (which I've already done). After that, I want to remove the selected items from SendBox. Later on I'm going to need the data from RecieveBox for something else, but I don't want repeated data (so I don't want the user to be able to select the data again).
What I tried doing was setting up an array that holds the index numbers of the selected items. After I dump the data into RecieveBox, I try and remove the entries from SendBox using the index array. The problem is that it's not working. Not all the items that were selected end up being deleted.
Here's the code:
As you can tell, this code is bound to a command button.
Sample data would be: (all data would be located in a single row beginning at location E3)
Jun-96
Jul-96
Aug-96
Sep-96
Oct-96
Nov-96
Dec-96
Jan-97
Feb-97
Mar-97
Apr-97
May-97
Jun-97
Jul-97
Any help would be appreciated.
What I tried doing was setting up an array that holds the index numbers of the selected items. After I dump the data into RecieveBox, I try and remove the entries from SendBox using the index array. The problem is that it's not working. Not all the items that were selected end up being deleted.
Here's the code:
Code:
Private Sub cmdAddListItem_Click()
Dim arrRemove() As Integer 'array storing index numbers
Dim e As Integer 'generic use variable
e = Me.SendBox.ListCount
ReDim arrRemove(1 To e)
e = 1
With Me.SendBox
For i = 0 To .ListCount - 1
If .Selected(i) Then
Me.ReceiveBox.AddItem .List(i)
arrRemove(e) = i
e = e + 1
End If
Next i
For i = 1 To e - 1
.RemoveItem arrRemove(i)
Next i
End With
End Sub
Sample data would be: (all data would be located in a single row beginning at location E3)
Jun-96
Jul-96
Aug-96
Sep-96
Oct-96
Nov-96
Dec-96
Jan-97
Feb-97
Mar-97
Apr-97
May-97
Jun-97
Jul-97
Any help would be appreciated.