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
This Excel VBA Code converts the excel range into HTML and also can convert Excel to HTML Table to paste data on Outlook Email Body
How to use VBA to open Workbook in Excel? There are few VBA codes which are commonly used by every developer. One of them is giving an option to user to browse a file. Below is a…
VBA Code To Add New Sheet In VBA, it is sometime important to add a worksheet at the right place in the Excel. Here is a simple an effective code that adds a new worksheet…
Have you ever felt that Microsoft should have added a formula in Excel which can count the cells based on specific color? I have seen many code requests to share a VBA code that can count the cells by its color. To help our subscribers and developers, we are sharing 2 codes that be used to count the cells with specific color and returns the count of the matching color cells.
This Excel VBA Code helps to Get User Name. Here is an example environ(username) or Application.username.This macro gets the username from active directory.
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 the Excel. The tool is fully dynamic, it can support any data format in Excel.