Using ListBox in Userform is very common. You can use ListBox.AddItem function to add items in the listbox.; however, it is little difficult to add items in Listbox when the number of columns are more than one.
'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
VBA Code to Read Outlook Emails Reading emails from Outlook and capture them in Excel file is very common activity being performed in office environment. Doing this activity manually every time is quite boring and…
VBA Code to Find Last used Column or Row in Excel Sometimes as a developer, you need to take actions in Excel sheets based on last row or column. In Excel, there are two kinds…
VBA Code to Browse a Folder Quite often a VBA developer requires code to browse a folder. This is mainly for saving the output file or reading the input file(s). Below is the VBA code…
How to Add Outlook Reference in Excel VBA? To automate Outlook based tasks from Excel you need to add Outlook Object Library (Microsoft Outlook XX.X Object Library) in Excel References. You can follow below steps…
VBA code that will sum cells by its color through excel function. This code will really help in making the analysis and presentation better.
Random Rows Selector is an MS Excel based tool which can be used to pick random or stratified samples from a set of records available in Excel.