Setting initial value on text box?

  • Thread starter Thread starter Chet
  • Start date Start date
C

Chet

Does anyone know how to set an initial value on a text box? I want
to go to a specific place on my worksheet and get the value that will
be the initial value and put it into the form that the user will then
either keep or change.

I read a post saying to use a private sub_initialize in my userform
code section that excel created for me and I put this code into it but
the value of Loc never shows up in the actual userform when I run my
code.

Private Sub UserForm1_Initialize()
Dim Loc As Range
Set Loc = Worksheets("Internals").Range("B4").CurrentRegion
TextBox1.Text = Loc
End Sub

Thanks,
Chet
 
Private Sub UserForm_Activate()
TextBox1.Text = Worksheets("Internals").Range("B4")
End Sub

Hth,
Merjet
 
A non-VBA way of doing this would be simply to set the "ControlSource"
of the TextBox to a named range. The default downside here (or upside,
depending on what you want) is that any change to the value in the
textbox would also change the value in the cell. To prevent that
automatic update behavior, you can set the 'Enabled' property of the
textbox to 'False'

/ Tyla /
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top