To close a userform:
Private Sub CommandButton3_Click()
Unload Me
End Sub
Or :
Private Sub CommandButton2_Click()
Unload UserForm1
End Sub
Or:
Private Sub CommandButton2_Click()
Me.Hide
End Sub
Rgds,
Halim
menuliskan:
Hi Bafa,
May be you can replace your :
Private Sub UserForm_Click()
Me.TextBox1.Value = Worksheets("User Input").Range("d11").Value
Me.TextBox2.Value = Worksheets("User Input").Range("d12").Value
Me.TextBox3.Value = Worksheets("User Input").Range("d13").Value
Me.TextBox4.Value = Worksheets("User Input").Range("d14").Value
Me.TextBox5.Value = Worksheets("User Input").Range("d15").Value
End Sub
'to:
Private Sub UserForm_Activate()
TextBox1.Value = sheets("User Input").Range("d11").Value
TextBox2.Value = sheets("User Input").Range("d12").Value
TextBox3.Value = sheets("User Input").Range("d13").Value
TextBox4.Value = sheets("User Input").Range("d14").Value
TextBox5.Value = sheets("User Input").Range("d15").Value
End Sub
So you will get the value while Userform1 loaded and showed up
Gary's right he shows you to open a Userform like:
'place in a standard module :
Sub ShowForm()
UserForm1.Show vbModeless
End sub
Vbmodeless will allow you to interact with main application "Excel",
remove it if you won't !
To change Label1 Caption:
Private sub CommandButton2_Click()
Label1.Caption = Sheets(1).Range("E38").Text
End Sub
Or:
Private sub CommandButton2_Click()
Label1.Caption = "Now set the Window Width to 1 _
and the Window Level to _
[Sheet1 E38] and measure the
diameter of the center dot."
End Sub
Rgds,
Halim
Bafa menuliskan:
You guys are my heros! I never thought I would understand any of this
code, but this simple example you gave me helped me understand the
basics so I can apply it to my workbook.
So now I have the ability to enter data from my User Form into my
worsheet like I want. My work sheet will take this data and run them
through an equation and I need the results to appear as text in a label
on the next page of my user form.
For example I will need the cell from Sheet1 E38 to show up like this
in a label:
"Now set the Window Width to 1 and the Window Level to [Sheet1 E38] and
measure the diameter of the center dot."
In addition to that can you also please give me the command button code
that will close UserForm1 and open UserForm2?:
This is what I have now for my first suer form and it works great.
Private Sub CommandButton1_Click()
Worksheets("User Input").Range("d11").Value = Me.TextBox1.Value
Worksheets("User Input").Range("d12").Value = Me.TextBox2.Value
Worksheets("User Input").Range("d13").Value = Me.TextBox3.Value
Worksheets("User Input").Range("d14").Value = Me.TextBox4.Value
Worksheets("User Input").Range("d15").Value = Me.TextBox5.Value
End Sub
Private Sub Label1_Click()
End Sub
Private Sub UserForm_Click()
Me.TextBox1.Value = Worksheets("User Input").Range("d11").Value
Me.TextBox2.Value = Worksheets("User Input").Range("d12").Value
Me.TextBox3.Value = Worksheets("User Input").Range("d13").Value
Me.TextBox4.Value = Worksheets("User Input").Range("d14").Value
Me.TextBox5.Value = Worksheets("User Input").Range("d15").Value
End Sub
Soon I will post a link to my workbook, but I still have basic equation
editing to do, so there is no point yet. Again thanks so much.
--
Bafa
------------------------------------------------------------------------
Bafa's Profile: http://www.excelforum.com/member.php...o&userid=37748
View this thread: http://www.excelforum.com/showthread...hreadid=573341