Reputation: 450
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.
Upvotes: 0
Views: 3685
Reputation: 10679
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
Upvotes: 3