[VBA] How to populate a textbox with formatted text?

MrD101

New Member
Joined
Sep 2, 2021
Messages
10
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I have text string in a cell on tab A. For example, let's say it is: "The red dog was very big."

I would like to populate a textbox on tab B with the string including the formatting of the string (the bold and color included). In my case a person would select a cell and click a button to populate the textbox on the other tab.

If I try to do something like this:
VBA Code:
Sheets("B").Shapes("TextBox 1").TextFrame.Characters.Text = ActiveCell.Value
I get the text but lose the formatting. I also tried ActiveCell.Text with no luck.

How can I accomplish this?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
UserForm TextBoxes cannot do that... all the text in them must be the same format.
 
Upvote 0
UserForm TextBoxes cannot do that... all the text in them must be the same format.
I was afraid that might be the answer. Are they any other options instead of a textbox that might be used for displaying longer strings that might be able to include formatting?
 
Upvote 0
You can do it for a Textbox on a sheet, but you need to loop through the characters like
VBA Code:
   Dim i As Long
   With Sheets("B").Shapes("TextBox 1").TextFrame
      .Characters.Text = ActiveCell.Value
      For i = 1 To Len(ActiveCell.Value)
         .Characters(i, 1).Font.Color = ActiveCell.Characters(i, 1).Font.Color
      Next i
   End With
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,453
Members
448,967
Latest member
grijken

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