Vba update listbox based on cell in Excel
For example, I have a Activex listbox "Countries". I want to populate it with the names listed in named range "COUNTRIES_SUPPORTED".
To do it in Excel, here is the answer:
- Option Explicit
- Sub AddEntriestoListBox()
- Dim cell As Range
- For Each cell In Range("COUNTRIES_SUPPORTED")
- ActiveSheet.Countries.AddItem cell.Value
- Next cell
- End Sub
a) Line 5 - 7 is used to loop through all cells in the named range and then add each entry to ActiveX listBox.
Result after Macro execution:
You can find similar Excel Questions and Answer hereunder
1) How to hide and unhide rows and columns in excel VBA
2) How to find the column number from the cell address in VBA
3) How can I enter a picture in a cell?
4) How can I set Page orientation, Zoom % , Title Rows and footer using VBA?
5) How do i put double quotes in a string in vba in Excel
6) How can I find the number of working days between 2 dates using VBA?
7) How to do workbook protection with VBA in Excel
8) I have a macro that takes a lot of time for execution - how can I keep the user informed that the macro is running?
9) How can I set non-contiguous print area using VBA?
10) Vba length of an array in Excel