18

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.

1
  • 1
    In case you were not aware you can create multiple instances of the same form, so you can dim frmEnterName as frmBaseForm ... then update the UI and set a flag indicating how to process subsequently Commented May 29, 2013 at 16:24

2 Answers 2

34

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

Sign up to request clarification or add additional context in comments.

1 Comment

Alternatively, export the file and use a text editor to rename the form within the .frm file and import.
5

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.

2 Comments

Much much simpler than the other answer.
At least in Word, you don't need to create anything new. You always have the active document + the Normal template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.