User Form Template???

N

novicevbaer

I have to create 60 user forms for an excel project. Is there a way t
create a template so that I don't have to keep changing the individua
user form control properties? Thank you in advance for an
suggestions
 
H

Harald Staff

Sure. Use the form as a class. Make one witha Label1 and a Commandbutton1
and then run this:

Sub Test()
Dim F1 As UserForm1
Dim F2 As UserForm1
Dim F3 As UserForm1
Dim F4 As UserForm1

Set F1 = New UserForm1
F1.Caption = "Hi"
F1.StartUpPosition = 0
F1.Top = 20
F1.Label1.Caption = "One"
F1.CommandButton1.Caption = "One"

Set F2 = New UserForm1
F2.Caption = "Hi"
F2.BackColor = RGB(230, 250, 150)
F2.Label1.Caption = "Two"
F2.CommandButton1.Caption = "Two"

Set F3 = New UserForm1
F3.Caption = "Hi"
F3.Label1.Caption = "3"
F3.CommandButton1.Caption = "3"

Set F4 = New UserForm1
F4.Caption = "Hi"
F4.Height = 500
F4.Label1.Caption = "Quattro"
F4.CommandButton1.Caption = "Quattro"

F1.Show
F2.Show
F3.Show
F4.Show

End Sub

HTH. Best wishes Harald
 
Top