Text Box Value

G

Guest

Two Possible answers to this one that will solve my problem... one from
Excel, one from VBA.

From Excel, is there a formula that will link a cell to a text box value?
-- If the value of "TextBox1" is "Test", is there a way to send this value
to cell A1.

From VBA, how do you refer to a text box from VBA?
-- I tried Sheets("Survey").TextBox(tbox) where tbox is a string with the
TextBox's name ("TextBox1" which changes with each text box). This returns an
error.

Thanks for your help :)
 
G

Guest

I figured out how to select the textbox using...
Sheets("Survey").Shapes("TextBox1").Select

and how to change the text in the box...
Sheets("Survey").Shapes("Text Box 125").Characters.Text = "test"

But how do I pull the value from the box...
 
G

Guest

Shoot me...

You have to use DrawingObjects

abc = Sheets("Survey").DrawingObjects("Text Box 125").Characters.Text
 
G

Guest

Demo'd from the immediate window (for textboxes from the drawing toolbar).
? activesheet.Textboxes("Text Box 1").Text
abcdefgh

Range("A1").Value = activesheet.Textboxes("Text Box 1").Text
? range("A1").Value
abcdefgh
Activesheet.Textboxes("Text Box 1").Text = " Why Hello there!"
? Activesheet.Textboxes("Text Box 1").Text & " " & Range("A1").Value
Why Hello there! abcdefgh

Manually, select the textbox

go to the formula bar and put in

=A1<enter>

Now they are linked.
 

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

Top