Copying text from one textbox to another

mcomp72

Active Member
Joined
Aug 14, 2016
Messages
275
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2011
Platform
  1. Windows
  2. MacOS
I have a textbox on one of my Excel sheets (created using Insert -> Text Box), and I want the text inside this textbox to appear inside a textbox that I have in a UserForm.

I have written code to try and make this happen, but it is not working, so I obviously don't understand the correct syntax to use. I have looked around at different forums looking for a solution, but every different variation of code I have tried hasn't worked. Whenever I run the UserForm, the textbox always appears empty.

Here's the code I have currently:

Code:
Private Sub UserForm_Initilize()

Dim txBox_source As Shape
Dim txBox_target As Shape
Dim TextToCopy As String

Set txBox_source = Sheets("Storage").Shapes("LATextBox")
Set txBox_target = Me.LA_TextBox

TextToCopy = txBox_source.Text

txBox_target.Text = TextToCopy

End Sub

Any help to make this work would be appreciated.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try this:
Code:
Private Sub CommandButton4_Click()
'Modified 7/7/18 2:15 AM EDT
Dim ans As String
ans = Sheets("Storage").Shapes.Range("LATextBox").TextFrame2.TextRange.Text
Me.TextBox2.Value = ans
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,766
Messages
6,126,761
Members
449,336
Latest member
p17tootie

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
Back
Top