Consulting

Results 1 to 3 of 3

Thread: Solved: Returning TextBox data to msgbox or cell

  1. #1
    VBAX Newbie
    Joined
    Jul 2011
    Posts
    2
    Location

    Solved: Returning TextBox data to msgbox or cell

    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.

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Welcome to the forum!

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

  3. #3
    VBAX Newbie
    Joined
    Jul 2011
    Posts
    2
    Location
    Cool, the control source did the trick. Thanks for the help, Ken.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •