简体   繁体   中英

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

在此处输入图片说明

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

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM