【问题标题】:How to display a worksheet on a form in excel-vba如何在 excel-vba 中的表单上显示工作表
【发布时间】:2017-03-30 01:03:53
【问题描述】:

我正在尝试在表单上显示工作表,但直到现在我还没有成功。它包含 15 列和大约 2000 行的工作表。有人能帮我吗?

【问题讨论】:

标签: excel vba


【解决方案1】:

构建一个带有列表框和按钮的表单。然后将此代码放入表单模块中。按钮的名称应为 CommandButton1,列表框的名称应为 ListBox1。

最后在列表框控件上将列数更改为 15。

Private Sub CommandButton1_Click()
    Unload Me
End Sub


Private Sub UserForm_Initialize()
    ' Activate the sheet that has the data you want displayed in the listbox
    Sheet1.Activate
    ' Put the range of the data you want displayed.
    ' Here I used columns "A" to "O" and 2000 rows
    ListBox1.RowSource = "A1:O2000"
End Sub

【讨论】:

  • 仍然存在问题,我刚刚注意到列表框没有显示所有列。我正在尝试另一张有 17 列的表格的行代码,它只显示 15 列。我还添加了这个 ListBox1.ColumnCount = 17,但它不起作用
  • 在编辑器中打开表单。查看属性框。您已将属性框中的属性物理更改为 17。您无法使用代码进行操作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-11-11
  • 2018-05-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多