PDA

View Full Version : Solved: Returning TextBox data to msgbox or cell



rbtrout
07-27-2011, 10:35 AM
Obviously, I'm fairly new to vba coding.

I've created a userform and added a textbox. I need to be able to close the textbox, but save the data from what was entered.
Unload will remove all from memory and screen, but I don't know what else to do or how to get the data stored to a variable.

Kenneth Hobs
07-27-2011, 11:04 AM
Welcome to the forum!

You could set the ControlSource property value to say Sheet2!A1 or something like:
Private Sub CommandButton1_Click()
Dim sVariable As String
sVariable = TextBox1.Value
Worksheets("Sheet1").Range("A1").Value = sVariable
Unload Me
End Sub

rbtrout
07-27-2011, 11:27 AM
Cool, the control source did the trick. Thanks for the help, Ken.