【问题标题】:How to add items to a combobox in a form in excel VBA?如何在excel VBA中的表单中将项目添加到组合框?
【发布时间】:2013-07-30 13:23:45
【问题描述】:

我是 VBA 新手。我想创建一个表单,用户选择组合框的一个项目并且选择运行一个宏。我在 VBA 中创建了一个用户表单,但我无法将项目添加到组合框。当用户打开表单时,我想要选择在已经加载的组合框中。我该如何做到这一点?

谢谢

【问题讨论】:

    标签: vba excel combobox


    【解决方案1】:

    我找到了这个;

    Excel VBA ComboBox Lists

    从这里开始;

    vba- Can a combobox present more then one column on it's textbox part?

    这可能会有所帮助;

    Populating ComboBoxes VBA

    我在这里添加了一个演示;

    Playing with populating boxes.xlsm

    【讨论】:

      【解决方案2】:

      我更喜欢的方法是将一组数据分配给组合框。单击用户窗体的主体并将“单击”事件更改为“初始化”。现在组合框将在初始化用户表单时填充。我希望这会有所帮助。

      Sub UserForm_Initialize()
        ComboBox1.List = Array("1001", "1002", "1003", "1004", "1005", "1006", "1007", "1008", "1009", "1010")
      End Sub
      

      【讨论】:

      • 有没有办法在 VBA 中动态创建组合框?每当工作簿打开时,我都需要在 sheet1 内的运行时创建一个。感谢任何关于此的指针。
      【解决方案3】:

      这是另一个答案:

      With DinnerComboBox
      .AddItem "Italian"
      .AddItem "Chinese"
      .AddItem "Frites and Meat"
      End With 
      

      来源:Show the

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-06-04
        • 1970-01-01
        • 1970-01-01
        • 2015-10-20
        • 1970-01-01
        • 2016-11-28
        • 2023-03-25
        相关资源
        最近更新 更多