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".

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

Description:

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 vba update listbox based on cell

 

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

 

Here the previous and next chapter