View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
LaDdIe LaDdIe is offline
external usenet poster
 
Posts: 131
Default Compare Contents of 2 listboxes

Could I please have assistance with the code below, my aim is to compare
contents of ListBox2 with ListBox1 if a match is found to remove it from
ListBox1;

Dim i As Long, j As Long

For i = 0 To ListBox2.ListCount - 1
DoEvents
ListBox2.ListIndex = i
For j = 0 To ListBox1.ListCount - 1
DoEvents
ListBox1.ListIndex = j
If InStr(1, ListBox2.List(ListBox2.ListIndex),
ListBox1.List(ListBox1.ListIndex)) Then
ListBox1.RemoveItem (j)
End If
Next j
Next i

End Sub