VBA Code To Add Items In Listbox Control
Here is a sample VBA code to help you
'Event handler to add list item in ListBox Private Sub cmdSubmit_Click() 'Add an item in the listbox lstDepartment.AddItem "Item Name" 'If listbox has more than one column then add column value 'Column 1 lstDepartment.Column(1, lstDepartment.ListCount - 1) = "Item " & lstDepartment.ListCount 'Column 2 lstDepartment.Column(2, lstDepartment.ListCount - 1) = "Item " & lstDepartment.ListCount End Sub
Commonly used ListBox properties
- Name: Can be used to define control name
- ColumnCount: Number of columns required in the listbox
- ColumnHeads: Defines whether you want to show header or not
- ColumnWidths: To change default Column width (e.g. 100 pt; 100 pt; 50 pt)
- Enabled: To enable or disable the control
- Height: To change height of the control
- Locked: To lock or unlock the control
- MultiSelect: To control the multiple selection options
- SpecialEffect: To change the look and feel of the control
- TabIndex: Tab index of the control
- Visible: To hide or unhide the control
- Width: To change the width of the control
Download Practice File
Excel VBA Course : Beginners to Advanced
We are offering Excel VBA Course for Beginners to Experts at discounted prices. The courses includes On Demand Videos, Practice Assignments, Q&A Support from our Experts. Also after successfully completion of the certification, will share the success with Certificate of Completion
This course is going to help you to excel your skills in Excel VBA with our real time case studies.
Lets get connected and start learning now. Click here to Enroll.
Secrets of Excel Data Visualization: Beginners to Advanced Course
Here is another best rated Excel Charts and Graph Course from ExcelSirJi. This courses also includes On Demand Videos, Practice Assignments, Q&A Support from our Experts.
This Course will enable you to become Excel Data Visualization Expert as it consists many charts preparation method which you will not find over the internet.
So Enroll now to become expert in Excel Data Visualization. Click here to Enroll.
Use Automated Excel Utility Tools to increase productivity
Hope you are enjoying learning Excel with us, if you want any support related to this article, please do comment else you can ask questions in Excel Community