ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   duplicate a user form? (https://www.excelbanter.com/excel-programming/296639-duplicate-user-form.html)

Pal

duplicate a user form?
 
Is it possible to duplicate a user form?
I have one that I want to use twice with only a slight modification.
I did not see an option to copy paste from the project section.

Thanks
Pal



Bob Phillips[_6_]

duplicate a user form?
 
File Export the form, rename the project one, or the file, and re-import it.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Pal" wrote in message
news:DWUjc.8038$RE1.813063@attbi_s54...
Is it possible to duplicate a user form?
I have one that I want to use twice with only a slight modification.
I did not see an option to copy paste from the project section.

Thanks
Pal





Harald Staff

duplicate a user form?
 
"Pal" skrev i melding
news:DWUjc.8038$RE1.813063@attbi_s54...
Is it possible to duplicate a user form?
I have one that I want to use twice with only a slight modification.


Hi Pal

Welcome tho the world of classes and objects. Plan a form flexible enough
and you can use it for infinite variations.

In an empty workbook, create one single Userform1 with CommandButton1 and
CommandButton2. Then in a standard module paste and run this:

Sub ThreeForms()
Dim U1 As UserForm1
Dim U2 As UserForm1
Dim U3 As UserForm1

Set U1 = New UserForm1
U1.BackColor = RGB(0, 0, 255)
U1.CommandButton1.Caption = "Yo da man !"
U1.CommandButton1.Top = U1.Height / 2 - _
U1.CommandButton1.Height / 2
U1.CommandButton1.Left = U1.Width / 2 - _
U1.CommandButton1.Width / 2
U1.CommandButton2.Visible = False
U1.Caption = "Yo da man ?"

Set U2 = New UserForm1
U2.BackColor = RGB(210, 255, 175)
U2.CommandButton1.Caption = "Absolutely"
U2.CommandButton2.Caption = "Neat !"
U2.Caption = "Beauty contest"

Set U3 = New UserForm1
U3.BackColor = RGB(255, 255, 0)
U3.CommandButton1.Caption = "Abort"
U3.CommandButton1.BackColor = RGB(255, 0, 0)
U3.CommandButton1.Top = 3
U3.CommandButton1.Left = 6
U3.CommandButton2.Top = 25
U3.CommandButton2.Left = 6
U3.CommandButton2.Caption = "Cancel"
U3.CommandButton2.BackColor = RGB(255, 0, 0)
U3.Caption = "Install Windows XP"

U1.Show
U2.Show
U3.Show

End Sub

HTH. Best wishes Harald



Bob Flanagan

duplicate a user form?
 
Copy the form to another workbook, rename the copy, then copy it back.

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"Pal" wrote in message
news:DWUjc.8038$RE1.813063@attbi_s54...
Is it possible to duplicate a user form?
I have one that I want to use twice with only a slight modification.
I did not see an option to copy paste from the project section.

Thanks
Pal






All times are GMT +1. The time now is 02:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com