【问题标题】:Creating a dynamic form in Excel Vba在 Excel Vba 中创建动态表单
【发布时间】:2015-09-20 21:59:11
【问题描述】:

我需要在 Excel 中创建一个表格;其大小和元素取决于我在宏中填充的数组。

所以,基本上,我拥有的是一个名为Activities(x) 的数组,其中包含x 元素。

x 可能会在每次宏运行时发生变化。我需要在每个列表旁边显示一个复选框,这将产生一个名为ActivitiesNew(y) 的新数组,其中y显然)小于x

我不知道如何使用 userForm 大小(以便我可以合并所有应该显示的元素)或每个复选框的标题,以便显示正确的文本。

【问题讨论】:

    标签: excel checkbox vba


    【解决方案1】:

    您可以像这样操作用户窗体的大小:

    'Suppose UserForm is the name of your element
    With UserForm
        .Height     
        .Width
    End With
    

    对于复选框:

    'Suppose CheckBox is the name of your element
    With CheckBox
        .Left       'Beginning of the checkbox compared to the left side of the UserForm
        .Width
        .Top        'Beginning of the checkbox compared to the top of the UserForm
        .Height
        .Caption    'Change the displayed text
    End With
    

    如果改变这些元素的位置和大小是你唯一想做的事情,这应该足够了。

    您还可以在使用 VBA 运行宏时创建 CheckBox:

    Set TheCheckBox = UserForm.Controls.Add("Forms.CheckBox.1", Visible = True)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-06
      相关资源
      最近更新 更多