简体   繁体   English

用户窗体组合框Excel VBA

[英]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. 之所以这么烦,是因为我尝试了到目前为止已经读过的每条建议,但我似乎无法通过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. 当然,这些是Initialize事件的一部分。 :) :)

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). 在您的userform初始化事件中添加您的代码,但添加对该用户窗体的引用(Me.Weeks)。

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

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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