Copy range of cells and paste into a basic text box

buske78

New Member
Joined
Jun 17, 2015
Messages
2
I would like to copy the values in the range of cells A1:A17 into a basic text box, called Textbox 2. Here is the code I am using:

Sheet6.Shapes("Textbox 2").TextFrame.Characters.Text = Sheet6.Range("A1:A17").Value

It keeps giving me an error of: Runtime error 13. Type mismatch.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
I am pretty sure you will need to concatenate those seventeen values into one string to do what you want. Without having tested this, it might work.

Code:
Sheet6.Shapes("Textbox 2").TextFrame.Characters.Text = Application.Concatenate(Sheet6.Range("A1:A17"))
 
Last edited:
Upvote 0
JWhiz

I don't think Excel VBA uses that function (Concatenate) so I built my own with a loop.

Code:
Dim n As Integer
Dim s As String


For n = 1 To 17
    s = s & Sheet6.Cells(n, 1)
Next
Sheets("Temp Data").Range("P1") = s
 
Upvote 0
JWhiz

I don't think Excel VBA uses that function (Concatenate) so I built my own with a loop.

Yep, the cells have to be entered individually instead of as a range for the CONCATENATE function. But you got the idea and came up with a solution.
Regards, JLG
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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