![]() |
Userform input into a particular cell
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 |
Userform input into a particular cell
Good evening MWS Something like this should do the trick, attached to your buttons code : Range("A1").Value=Textbox1.Value HTH DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=483225 |
Userform input into a particular cell
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 -- - K Dales "MWS" wrote: 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 |
Userform input into a particular cell
I will try this - Thank You for Your Assistance, I appreciate your help and
quick response. Take Care "K Dales" wrote: 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 -- - K Dales "MWS" wrote: 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 |
All times are GMT +1. The time now is 05:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com