Hi guys,
I am trying to copy selected items from a multi-column listbox to another (At this stage I want columns 1,2 and 5 copied across to columns 0, 1, 2 in the second listbox on a separate userform). I have written the following code, however it is only showing the last selected value in the new listbox. I am sure it is a simple fix, but I cannot for the life of me figure it out (I am new at coding in general, so that doesn't help). Perhaps I need to save the values in a temp array? Either way, any assistance would be greatly appreciated. Thanks!
I am trying to copy selected items from a multi-column listbox to another (At this stage I want columns 1,2 and 5 copied across to columns 0, 1, 2 in the second listbox on a separate userform). I have written the following code, however it is only showing the last selected value in the new listbox. I am sure it is a simple fix, but I cannot for the life of me figure it out (I am new at coding in general, so that doesn't help). Perhaps I need to save the values in a temp array? Either way, any assistance would be greatly appreciated. Thanks!
Code:
Dim i As Integer
Dim J As Integer
For i = 0 To Me.ListSearch.ListCount - 1
If Me.ListSearch.Selected(i) = True Then
Checkout.ItemList.AddItem
Checkout.ItemList.List(J, 0) = Me.ListSearch.List(i, 1)
Checkout.ItemList.List(J, 1) = Me.ListSearch.List(i, 2)
Checkout.ItemList.List(J, 2) = Me.ListSearch.List(i, 5)
End If
Next i
Checkout.Show
End Sub