Back to: Excel VBA . Got any Excel/VBA Questions? Free Excel Help
Multi Select ListBox Download Multi Select ListBox Example
When using a ListBox we can do so in a way that can allow users to make
multiple selections from the ListBox. After they have made their selection(s)
normally a CommandButton would be used to take those selections and place
them onto a Worksheet or another UserForm Control.
Single Selection ListBox
As mentioned above, we can have our user select one, or more items in a ListBox. The procedure below take a single selected ListBox item and places it into a range at the bottom of a list.
Sheet2.Range("A65536").End(xlUp)(2, 1) = ListBox1.Value
For such code to work the ListBox must have its MultiSelect Property set to 1 fmMultiSelectSingle
MutliSelect Property is -1 fmMultiSelectMulti
When have set the MultiSelect Property set to -1 fmMultiSelectMulti we can allow users to make multiple selections. However, due to MultiSelect Property set to -1 fmMultiSelectMulti we can no longer use simple code like above to return the selected items to our cells. To do this with multiple selections we can use code like shown below;
Private Sub CommandButton2_Click() Dim lItem As Long For lItem = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(lItem) = True Then Sheet2.Range("A65536").End(xlUp)(2, 1) = ListBox1.List(lItem) ListBox1.Selected(lItem) = False End If Next End Sub
Download Multi Select ListBox Example
Excel Dashboard Reports & Excel Dashboard Charts 50% Off Become an ExcelUser Affiliate & Earn Money
Special! Free Choice of Complete Excel Training Course OR Excel Add-ins Collection on all purchases totaling over $64.00. ALL purchases totaling over $150.00 gets you BOTH! Purchases MUST be made via this site. Send payment proof to email@example.com 31 days after purchase date.
Instant Download and Money Back Guarantee on Most Software
Excel Trader Package Technical Analysis in Excel With $139.00 of FREE software!
Microsoft ® and Microsoft Excel ® are registered trademarks of Microsoft Corporation. OzGrid is in no way associated with Microsoft
Some of our more popular products are below...
Convert Excel Spreadsheets To Webpages | Trading In Excel | Construction Estimators | Finance Templates & Add-ins Bundle | Code-VBA | Smart-VBA | Print-VBA | Excel Data Manipulation & Analysis | Convert MS Office Applications To...... | Analyzer Excel | Downloader Excel | MSSQL Migration Toolkit | Monte Carlo Add-in | Excel Costing Templates