userform
Antonov,
You input the code "behind" the cmdOK button. This is how
you do it: First make the button on the form. Name it
cmdOK (or whatever you would like) in the properties
section. Write the caption as "Enter" also in the
properties section.
Now double click this newly created button. You should
see this:
Private Sub cmdOK_Click()
End Sub
Now put Losmac's code or my code in there. Both should
work. I hope that helps.
Losmac's code is a little different. The text box in this
case, is named "TextBox1", instead of "txtNo1". He's
referring to a sheet called "name" (rather than the second
sheet "Sheet(2)") and a cell at the top-left (rather than
at row 10, column E). Also it's written for a "formula"
(rather than just a "value").
For fun, you could put both codes in this subroutine like
this, with two Text boxes on your form. One text box
would be called "TextBox1", and the other one would be
called "txtNo1". Make sure one of your Excel workbook
worksheets is called "name". This would be the code:
Private Sub cmdOK_Click()
Dim tw As Workbook
Dim S2 As Worksheet
Dim NM As Worksheet
Set tw = ThisWorkbook
Set S2 = tw.Sheets(2)
Set NM = tw.Sheets("name")
S2.Cells(10, 5).Value = Me.txtNo1.Value
NM.Range("A1").Formula = Me.TextBox1.Text
End Sub
Add a "cmdExit" button to your form. Double click this
newly created exit button and put in this code:
Private Sub cmdExit_Click()
End
End Sub
Or you could write:
Private Sub cmdExit_Click()
Unload Me
End Sub
Rick
-----Original Message-----
Hi there Losmac
where do I have to input the code? I have tried it but
nothing happened
"losmac" wrote in message
...
Hello Antonov,
The simplest way to do it with code is:
TextBox1.Text = ThisWorkbook.Worksheets("name").Range
("A1").Formula
Użytkownik "Antonov" napisał w
wiadomości
...
hello everybody. I have a question: I need a userform
to have a cell or
a
text box or whatever in which I can see the content
of a cell in a
workbook
(i.e. =sheet!2 e10). is it possible?
.
|