baller1013
New Member
- Joined
- Sep 7, 2017
- Messages
- 15
I have a user form that has two listboxes (listbox1 and listbox2). When a user selects the value from listbox1 and adds it to listbox2, using command button, I would like the selection to disappear from listbox1. Additionally, if the user removes the selection from listbox2, I would like to add it back to listbox1. The listboxes are multicolumn (2) and multiselect. This is for a project so any help you can provide would be greatly appreciated. The following code I have that allows the user to select a value from listbox1 and add it to listbox2 is below. I have not been able to get the value to be removed from listbox1 as of yet. Thanks again!
Code:
If ListBox1.ListIndex = -1 Then Exit Sub
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
ListBox2.AddItem ListBox1.List(i, 0)
ListBox2.List(ListBox2.ListCount - 1, 1) = ListBox1.List(i, 1)
ListBox1.RemoveItem
End If
Next I
End Sub