Doug Coats February 2016

Userform Combo boxes Excel VBA

So kind of annoying because I have tried every suggestion that I have read so far, ut I cannot seem to get my user form combo boxes to be filled via VBA.

I have tried the following methods that seem to work for everyone but me....

 Me.Weeks.List = Array("30", "36", "40")

And....

 With Weeks
     .AddItem "30"
     .AddItem "36"
     .AddItem "40"
 End With

And so far nothing shows up in the userform when I run it. Is there a setting I am missing? Of course these are part of the initialize event. :)

MORE CODE PER REQUEST:

 Private Sub ToolBoxForm_Initialize()

Weeks.Clear
'MORE STUFF

Me.MinAYWeeks.List = Array("30", "36", "40")

'With MinAYWeeks
'    .AddItem "30"
'    .AddItem "36"
'    .AddItem "40"
'End With

'MORE STUFF

 End Sub

There's also stuff that does calculations with the OK button, but nothing that affects the contents of the combobox, just stuff that references the value of the selected option.

Thanks in advance guys

enter image description here

Answers


SincereApathy February 2016

In your userform initialize event add your code, but add a reference to the userform (Me.Weeks).

With Me.Weeks
 .AddItem "30"
 .AddItem "36"
 .AddItem "40"
End With

enter image description here

Post Status

Asked in February 2016
Viewed 2,600 times
Voted 8
Answered 1 times

Search




Leave an answer