Making an exact copy of a userform

mortgageman

Well-known Member
Joined
Jun 30, 2005
Messages
2,015
Is there a way to make a copy of an existing userform (with all its controls) into a new userform?

Gene, "The Mortgage Man", Klein
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
mortgageman,

this is my way:
create new workbook
goto VBA-Editor
drag form into new workbook project
change it's name
drag it back to original workbook

kind regards,
Erik
 
Upvote 0
You can Export the form, then rename it in the VBE and re-import it under the original name.
 
Upvote 0
I have used the Export/ Import option with success
Right click the form from the project window (left side vb)
and choose export, save
then choose import by right clicking in same window ....
 
Upvote 0
You can also create as many instances of an object as you wish. For example, you have a userform named userform1...

Code:
Sub Example()
    Dim f1 As New UserForm1, f2 As New UserForm1
    
    f1.Show vbModeless
    f2.Show
End Sub

...will show two separate instances of userform1. Modeless only applies to office 2000 and up...

Tom
 
Upvote 0
Right_Click: I tried using your idea in the following code - I want the "second" instance if the user right clicks. I got an error saying the the "top" needs to be closed first? Any ideas?

Gene, "The Mortgage Man", Klein

Private Sub OptionButton1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim f1 As New UserForm1
If Button = 1 Then
MsgBox "Your left click code goes here", , "Left button"
ElseIf Button = 2 Then
UserForm1.Hide
f1.Show
End If
End Sub
 
Upvote 0
Hi Gene.

I'm not suggesting that you use the method I showed. It's just an option and usually better coding practice if you need two objects that vary little from one another. Also, I have never seen that error and would need to see more or perhaps all of the relevant code to understand what the problem is...

Tom
 
Upvote 0

Forum statistics

Threads
1,214,531
Messages
6,120,073
Members
448,943
Latest member
sharmarick

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top