Hello,
I am in a tight jam, as my project is due tomorrow and I am now encountering an error for the first time. My assumption is that I coded for Excel 2003 and am testing on excel 2007 right now, but I cannot confirm that is the cause of the error.
I have a user form with two source listboxes: (1) listcg (2) listmc that are added to listselected when the "add button" is clicked. The problem is now removing an item from the listselected lsitbox back to the original source listbox.
I select ALL of the items in listCG and move them to listselected. Now the error ONLY occurs when I remove the items from listselected in a different order. In other words, the code works if I have items remaining in listCG still or if I remove from listSelected in order top to bottom.
The code is meant to return the item to the exact order it was in before adding to listSelected = alphabetically. If it was not originally in listCG, it checks to add back to listMC.
again, the code only breaks down when there are no items remaining in listCG or when removed out of order. breakdown point is
PLEASE HELP!
Private Sub cmdRemove_Click()
Dim icounter3 As Integer
Dim i As Integer
Dim found As Boolean
Dim c01 As String
If listSelected.ListIndex = -1 Then Exit Sub
For icounter3 = 0 To listSelected.ListCount - 1
If listSelected.selected(icounter3) Then
c01 = listSelected.List(icounter3)
listSelected.RemoveItem icounter3
For i = 0 To UBound(CorrelArrayCG)
Debug.Print CorrelArrayCG(i) & " " & c01
If CorrelArrayCG(i) = c01 Then
found = True
listCG.AddItem c01, i
Exit For
End If
Next
If found = False Then
For i = 0 To UBound(CorrelArrayMC)
If CorrelArrayMC(i) = c01 Then
listMC.AddItem c01, i
Exit For
End If
Next
End If
End If
Next icounter3
End Sub
Bookmarks