vba update listbox based on cell in Excel

Q165. In Excel, how can I update a listbox based on data in a list using VBA?

For example, I have a Activex listbox "Countries". I want to populate it with the names listed in named range "COUNTRIES_SUPPORTED".

excel vba update listbox based on cell

To do it in Excel, here is the answer:

  1. Option Explicit
  2. Sub AddEntriestoListBox()
  3. Dim cell As Range
  4. ''
  5. For Each cell In Range("COUNTRIES_SUPPORTED")
  6. ActiveSheet.Countries.AddItem cell.Value
  7. Next cell
  8. 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:

excel excel vba update listbox based on cell


You can find similar Excel Questions and Answer hereunder

1) How can I extract file name from a full path including folder path and file name?

2) Write to text file without quotes in vba in Excel

3) How can I add and link a Chart Title to a cell value?

4) How can I add a Timestamp after macro execution?

5) Highlight row of selected cell in Excel

6) How can I hide all comments in my WorkSheet using VBA?

7) I want to pull data from a table using a reference cell in table. Is there a function to support that?

8) How can I ensure that user enters only certain acceptable values in an input cell?

9) How can I save a WorkSheet as a new WorkBook using VBA?

10) I have a large list of clients whose current Age I need to maintain in my database as it influences costs - how can I have Excel display the current age at all times?

11) How can I shade alternate rows in color using VBA to make it easier to read voluminous data running into hundreds of rows?

12) How do I add a shape using VBA?

13) How can I dynamically add series to an existing chart using VBA?

14) How can I avoid updates to cell values during macro execution?

15) How can I get users to select a folder to save the output of my macro?