Reputation: 151
The problem is I've already created an UserForm and now I need another one with the same design and code.
I tried to perfom the usual copy/paste with the UserForm selected but It doesn't work. In fact, the option copy/paste appears disabled in the edition group in VBA Editor.
I've already tried to export the UserForm and change the name at the time to save it and import it again in my proyect but It retuns me a name matching error.
As I show in the following image I exported the UserForm with another name from the original UserForm which name is UserForm1, instead I saved this one as UserForm2.
This action returns me an error about the name 'UserForm1' is already used.
I need to duplicate this UserForm in my proyect changing the name
Upvotes: 0
Views: 5311
Reputation: 1485
For anyone coming to this thread because they want to use the same form in the same project, follow the advice provided by @ Tomek Kubiak.
For everyone else, I supposed you "could" Export/Rename/Import but you'd have to open a menu and select export and deal with the hassle of saving a file and that's not even half of it, you have to open another menu to get it back in addition to remembering where you saved it. And rename it!?! That's too much work for me to keep track of and if you're like me you've already forgotten the third step.
So what I do, is open a second instance of Excel, drag the module over to that project and then drag it back. Technically I suppose it can be argued that you're still exporting, renaming, and importing... But it sure doesn't feel like it.
.
Upvotes: 3
Reputation: 106
That's because the proper name of the Form is hidden inside the file and the file name itself is ignored during the form import. If you actually need to have a second UserForm just in the project, then I'd suggest to do as follows:
However I'd suggest to consider creating an another instance of the form and amend it dynamically if neccessary - that may help to avoid updating each UserForm separately.
e.g.:
dim f1 as new UserForm1
dim f2 as new UserForm1
f1.show
f2.show
Upvotes: 4