Multiselect ListBox for 2 column using Excel VBA

liaaa

New Member
Joined
Sep 29, 2023
Messages
20
Office Version
  1. 2010
Platform
  1. Windows
Hello,
I want to make a listbox that contain 2 columns, ID and Item name. It is possible to choose multiple items in listbox with 2 column and transfer the data to the worksheet?
I also have a lot of items, so I think I must make a search bar for the listbox.
So first I search id on the search bar, select that item on listbox (the listbox must show 2 column), and then transfer the id and items to worksheet.


I have try to use combo box and listbox, but its not working.

Private Sub CmbITEM_Change()
Me.LbITEM.AddItem Me.CmbITEM
For x = 1 To 2
Me.LbITEM.List(LbITEM.ListCount - 1, x) = Me.CmbITEM.Column(x)
Next x
End Sub


Private Sub UserForm_Initialize()
CmbITEM.List = Sheet2.Range("A2:A1000").Value

Dim i As Long
For i = 1 To Apllication.WorksheetFunction.CountA(Sheet2.Range("A:A"))
Me.CmbITEM.AddItem Sheet2.Cells(i, 1)
For x = 1 To 2
Me.CmbITEM.List(CmbITEM.ListCount - 1, x) = Sheet2.Cells(i, x + 1)
Next x
Next i

End Sub


Thank you for your help :)
 

Attachments

  • 1696607536838.png
    1696607536838.png
    10.8 KB · Views: 9

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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