Duplicate custom form in Excel VBA

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

Thus, I will only need to change the "names" of the command button in each form and nothing else.

I tried to export the form and import it, but it gives the error message "Name is already in use"

Any help would be appreciated.

+8
source share
2 answers

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

+17
source

Another method:
With your desired workbook ...
Create a new book (Ctrl + N) (by default it is called Book1), then
in the VBA project window (Ctrl + R),
drag the shape you want and
put it on the new VBAProject workbook (Book1). (The small plus sign under the cursor means that you are doing everything right.)
Now double-click the form you just created. (You may need to click the plus sign in front of the Forms folder to display it), and then
in the properties window (F4) change β€œName” to something unique.
Now back to the VBA project window
drag this new form back to the original VBAP project.
Done.

For multiple forms, repeat the last 2 steps.

0
source

Source: https://habr.com/ru/post/1483381/


All Articles