Kartik Anand
Kartik Anand

Reputation: 4609

Duplicate User Form in Excel VBA

I want to duplicate form in excel vba, this is necessary because I have applied some formatting to the form and now want all my forms to have the same formatting.

In this way I'll have to only change the "names" of command button in each form and nothing else.

I tried exporting the form and then importing it, but it gives an error saying "The name is already in use"

Any help would be appreciated.

Upvotes: 18

Views: 54376

Answers (2)

Stax
Stax

Reputation: 514

Another method:
With your desired workbook open...
Create a new workbook (Ctrl+N) (by default called Book1) then
within the VBA Project window (Ctrl+R),
drag the form you want, and
drop it onto the new workbook VBAProject(Book1). (a small "plus" under the cursor indicates you're doing it right.)
Now Doubleclick the form you just created. (You may need to click the "plus" in front of the Forms folder to display it) and then
in the Properties window (F4) change the "Name" to something unique.
Now back in the VBA Project window
drag and drop this new form back to your original VBAProject.
Done.

For multiple forms repeat the last 2 steps.

Upvotes: 5

user2140173
user2140173

Reputation:

Temporarily change the form name, export it, change the name back, then import the UserForm file. That way they do not match.

Upvotes: 34

Related Questions