Coding problem inserting text into text box

Derek

Well-known Member
Joined
Feb 16, 2002
Messages
1,592
Hi

Can anyone help me with this coding problem that has been driving me nuts.

I want to select a text box and insert text, as in this example which works well.
Selection.Characters.Text = "mytext"

However what I am trying to do is for it to accept the text in A1 of the activesheet. I have tried code like this without success:

Selection.Characters.Text = "mytext" & Range("A1").Value
Selection.Characters.Text = Range("A1").Value

Also tried to dim Range("A1").Value as a string or variant without success.

Please can someone explain to me the correct way of doing this.

Many thanks in advance

regards
Derek
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
hi!
try this!
On design mode click properties and activate the textbox.
then look for the link cell and type A1.
anything you type in A1 will be refelcted in the textbox.
 

Derek

Well-known Member
Joined
Feb 16, 2002
Messages
1,592
Thanks Sixth Sense, I didn't think of that but how would I code that? My code opens a new text box, names it, then needs to insert whatever is in A1. After a bit of jiggerypoker it then deletes the text box.
After the initial load from A1, it doesn't need the link to A1 anymore. The advantage to me would be that I can easily change the text in A1 without having to change the code itself.

regards
Derek
 

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
so you wan that be done in code

try this!

<font face=Courier New>TextBox1.LinkedCell = "A1"</FONT>

and to remove the link

<font face=Courier New>TextBox1.LinkedCell = ""</FONT>
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,819
Messages
5,772,461
Members
425,760
Latest member
paphon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top