Userform input into a particular cell

G

Guest

Can someone tell me how I can take the value a user would enter into a
textbox of a userform and place that value into a particular worksheet cell
(ie cell A1).

For instance, I have "userform1" displayed upon the activate event of the
worksheet.

The value a user inputs into "textbox1", which is on "userform1", I want to
be valued into cell A1.

There is also "commandbutton1" on the form and I was thinking the code to
value cell A1 was needed upon the click event of the button and before the
code to hide the userform.

Any and all help would be appreciated. Thank You
 
D

dominicb

Good evening MWS

Something like this should do the trick, attached to your buttons code
:

Range("A1").Value=Textbox1.Value

HTH

DominicB
 
G

Guest

In the CommandButton1_Click code you could put the following:

Sub CommandButton1_Click()

Worksheets("Sheet1").Range("A1").Value = UserForm1.TextBox1.Value
UserForm1.Hide

End Sub

Even better would be to have your code test the value of the textbox to make
sure it is appropriate - for example, if it must be a date:

Sub CommandButton1_Click()
Dim DateOK as Boolean

DateOK = IsDate(UserForm1.TextBox1.Value)
If Not (DateOK)
MsgBox "Input value must be a date"
Else
Worksheets("Sheet1").Range("A1").Value = UserForm1.TextBox1.Value
UserForm1.Hide
End If

End Sub
 
G

Guest

I will try this - Thank You for Your Assistance, I appreciate your help and
quick response. Take Care
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top