Copy Selected MultiColumn Listbox Values to Another Listbox

Joel11

New Member
Joined
Jul 11, 2019
Messages
1
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!

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
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top