+ Reply to Thread
Results 1 to 3 of 3

Populating a ComboBox in a UserForm

  1. #1
    Registered User
    Join Date
    06-20-2006
    Posts
    39

    Populating a ComboBox in a UserForm

    Hi everyone,

    My main question is: how do I populate a combobox located in a userform with items from an array? I thought I would use .AddItem like I would a listbox, but it simply will not populate. Here is the code:

    Please Login or Register  to view this content.
    Any advice? Thanks in advance.

    -- Isaac

  2. #2
    Registered User
    Join Date
    06-02-2006
    Posts
    39
    Currently, you're trying to add items to a combobox under a change event. The combobox will populate if you enter a value in or somehow change the text/value shown in a combobox. I think you're looking for something that will load the combobox on start, in which case put the code under a userform_initialize event. Something like this:

    Private Sub UserForm_Initialize()
    Dim MyArray As Variant
    Dim Ctr As Integer

    MyArray = Array("Item1", "Item2", "Item3", "Item4", "Item5")

    For Ctr = LBound(MyArray) To UBound(MyArray)
    ComboBox1.AddItem MyArray(Ctr)
    Next Ctr
    End Sub

  3. #3
    Registered User
    Join Date
    06-20-2006
    Posts
    39
    Thanks a whole lot Kev. I appreciate it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1