VBA 用户窗体数组

发布于 2024-08-08 10:40:23 字数 172 浏览 4 评论 0原文

目前,我有一个 Excel 电子表格,其中包含一些数据和一个命令按钮,该按钮创建一个显示该数据子集的用户窗体。用户窗体的设计方式使数据更易于查看。我遇到的问题是我希望命令按钮创建用户窗体的多个实例,以便每个窗体可以显示一组不同的数据。

我对 VBA 还很陌生,所以任何建议或只是一个让我入门的地方将不胜感激。谢谢。

Currently, I have an Excel spreadsheet with some data and a command button that creates a UserForm that displays a subset of that data. The UserForm has been designed in a way that makes the data easier to view. The problem that I'm having is that I would like the command button to make multiple instances of my UserForm so that each form can show a different set of data.

I'm pretty new to VBA so any suggestions or just a place for me to get started would be greatly appreciated. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灼痛 2024-08-15 10:40:23

确保 UserFormShowModal 属性设置为 False,否则只有一个 UserForm 实例可以立即显示。

之后,就很简单了:

Dim ufArray(0 To 4) As UserForm1
Dim i As Integer

For i = 0 To 4
    Set ufArray(i) = New UserForm1
Next i

For i = 0 To 4
    Load ufArray(i)
    ufArray(i).Show
Next i

显示 UserForm1 的五个独立副本

Make sure that the ShowModal property of the UserForm is set to False as otherwise only one instance of the UserForm can be shown at once.

After that, it is as simple as:

Dim ufArray(0 To 4) As UserForm1
Dim i As Integer

For i = 0 To 4
    Set ufArray(i) = New UserForm1
Next i

For i = 0 To 4
    Load ufArray(i)
    ufArray(i).Show
Next i

to show five independent copies of UserForm1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文