PDA

View Full Version : Solved: Show text from textbox on worksheet in textbox on userform



ceeejayy
04-25-2007, 08:45 AM
In Excel, there are:

1) A text-containing Autoshape Text Box ("tbWorksheet") residing in a Worksheet .
2) A vba object textbox ("tbUserForm") residing in an attached UserForm.

I wish to link tbWorksheet and tbUserForm such that text in tbWorksheet appears in tbUserForm.

I have tried various linkages utilizing control source property, tb__.Text, tb__.Value, etc but can't make it work. Tr?s frustrant.
Any assistance is greatly appreciated. Thanks in abundance.

lucas
04-25-2007, 08:54 AM
is the textbox on the sheet from the forms toolbar or the vb control toolbox?

ceeejayy
04-25-2007, 09:27 AM
The worksheet textbox originates from the Drawing toolbar, not the Control nor the Forms nor the Visual Basic toolbars. Excel seems to regard the textbox as a Shape.

lucas
04-25-2007, 10:23 AM
this seems to work for me:

Private Sub UserForm_Initialize()
TextBox1.Text = Worksheets(1).Shapes("Text Box 1").TextFrame.Characters.Text
End Sub

ceeejayy
04-25-2007, 12:00 PM
this seems to work for me:

Private Sub UserForm_Initialize()
TextBox1.Text = Worksheets(1).Shapes("Text Box 1").TextFrame.Characters.Text
End Sub
Dear Lucas,

Mirabile dictu, your code is perfect. Thanks for solving my simple but thorny problem.