views:

279

answers:

1

I'm having difficulties with a Combobox in a userform in an Excel document. The combobox either doesn't appear in the userform, or the combobox remains blank, and when I enter any character in it, the list of items appears, but 2 or 3 times, instead of just once. When I select an item, the chosen item doesn't appear in the box. It seems as if Excel^picks one at random, and whichever item I choose from the list, it's always the same one that ends up being displayed in the box.

Can anyone help me on this one? Thanks a lot!!!

This is the code I used:

Private Sub ComboBox1_Change()
    Select Case ComboBox1.Text
        Case "Een nieuwe start"
        Case "Alles heeft zijn tijd"
        Case "De wereld aan je voeten"
        Case "Een levend boek"
        Case "Drempels"
        Case "Kerstmis"
        Case "Confituur of choco"
        Case "Hoe groot is de hemel?"
        Case "Ongelovige Thomas"
        Case "Feesten"
        Case "Er is er één jarig!"
        Case "Eén van hart"
        Case "Ervoor gaan"
        Case "Groen gras"
        Case "RELatie"
        Case "Vele plaatjes"
        Case "Iedereen fan"
        Case "Schattenjacht"
        Case "Lichtbakens"
        Case "Rijke Luis"
        Case "Hemel op aarde"
        Case "Op bezoek"

        Case Else
    End Select
End Sub

Private Sub UserForm1_Initialize()
        ComboBox1.Clear
        ComboBox1.AddItem "Een nieuwe start"
        ComboBox1.AddItem "Alles heeft zijn tijd"
        ComboBox1.AddItem "De wereld aan je voeten"
        ComboBox1.AddItem "Een levend boek"
        ComboBox1.AddItem "Drempels"
        ComboBox1.AddItem "Kerstmis"
        ComboBox1.AddItem "Confituur of choco"
        ComboBox1.AddItem "Hoe groot is de hemel?"
        ComboBox1.AddItem "Ongelovige Thomas"
        ComboBox1.AddItem "Feesten"
        ComboBox1.AddItem "Er is er één jarig!"
        ComboBox1.AddItem "Eén van hart"
        ComboBox1.AddItem "Ervoor gaan"
        ComboBox1.AddItem "Groen gras"
        ComboBox1.AddItem "RELatie"
        ComboBox1.AddItem "Vele plaatjes"
        ComboBox1.AddItem "Iedereen fan"
        ComboBox1.AddItem "Schattenjacht"
        ComboBox1.AddItem "Lichtbakens"
        ComboBox1.AddItem "Rijke Luis"
        ComboBox1.AddItem "Hemel op aarde"
        ComboBox1.AddItem "Op bezoek"
        ComboBox1.Text = ComboBox1.List(0)
End Sub
A: 

You have UserForm1_Initialize which will never get called, it must be UserForm_Initialize (no "1")

Alex K.
Thanks Alex, that did the trick! Kind regards, Marc
Marc