Userform input into a particular cell

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Good evening MWS

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

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

HTH

DominicB
 
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
 
I will try this - Thank You for Your Assistance, I appreciate your help and
quick response. Take Care
 
Back
Top