Laissez passer Jail cell Value To UserForm TextBox As Text

    • #i

    Hi,
    I am new to this forum and not actually sure how this question will exist routed.

    I am trying to learn how to write a macro and create a UserForm. While doing so, I ran into a problem trying to capture an existing data in a cell ("C5") from a sheet chosen details. I merely wanted to display the content of cell "C5" into the textbox that I created in my UserForm.

    I capeesh any help and thanks to the technology like this.

    Thank you and Regards,

    • #2

    Re: Capture Data From Sheet To Show In Userform

    There are ii techniques that you lot can use.
    Putting this in a normal module

                                                                                        UserForm1.TextBox1.Text = CStr(Range("c5").Value)                                                                                                                    UserForm1.Show                                                                              


    Will put C5'south contents into the textbox before the userform is shown. Replacing CStr(Range("c5").Value) with a variable gives you command over which value goes into the text box.

    If you know that C5's value volition ever be the intial value of the text box, this code can be put in the UserForm'due south code module. The range is fully qualified to insure that which sheet is agile doesn't impact the right value being put in the text box. This consideration as well applies to the other technique, but since the range reference is outside of the userform, its less of a suprise.

                                                                                        Individual Sub UserForm_Initialize()                                                                                                                    Me.TextBox1.Text = CStr(ThisWorkbook.Sheets("Sheet1").Range("C5").Value)                                                                                                                    End Sub                                                                              

    In both cases

    volition erase the contents of the text box. The textboxe's value must exist put in a cell or variable before that line is executed

    • #3

    Re: Capture Data From Canvas To Bear witness In Userform

    Information technology works, thank you very much.

    • #4

    Re: Capture Information From Sheet To Show In Userform

    Glad to have helped.