A-1 ListBox (style =1) select
For Beginners. Copy the contents of ListBox1 to ListBox2 where the contents of ListBox1 is checked off. Remove any duplicates from ListBox2 and remove contents of ListBox2 where the contents of ListBox1 becomes unselected. (uhmmm... hope that made sense)
Original Author: twentyleafclover
Code
Private Sub List1_Click()
Dim X As Long
Dim y As Long
Dim j As Long
j = 0
' Add selected items to ListBox2
For X = 0 To List1.ListCount - 1
If List1.Selected(X) = True Then
List2.AddItem List1.List(X)
End If
Next
' Get rid of the now unselected items
Dim i As Long
For y = 0 To List1.ListCount - 1
For i = 0 To List1.ListCount - 1
List2.Text = List2.List(i)
If List2.List(i) = List1.List(y) And List1.Selected(y) = False Then
List2.RemoveItem i
End If
Next i
Next
'Get rid of any duplicates in ListBox2
Do While j < List2.ListCount
List2.Text = List2.List(j)
If List2.ListIndex <> j Then
List2.RemoveItem j
Else
j = j + 1
End If
Loop
End Sub
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.