how to format text in textbox or when copying to cell

davidmyers

Board Regular
Joined
Jan 29, 2017
Messages
88
Office Version
  1. 2016
Platform
  1. Windows
Hi,
I understand it's not possible to format text in a vba textbox, I need to copy the textbox content to a cell eg. in the textbox I have:

1. bla bla bla
2. bla bla bla
3. bla bla bla

What I want to see in the cell is:

1. bla bla bla
2. bla bla bla
3. bla bla bla

Is it possible to do this with vba code after I copy the textbox content to the cell, that is make bold the number at the start of each line?

Thanks for any help
David
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
David

hi

the following codes does what you need for the activecell, and would 'just' need adapting for use with the textbox, so I hope it helps!

Code:
Sub FormatSometext()
 
Dim Text As String
Text = "1.   bla bla bla"
With ActiveCell
    'set content to our text
    .Value = Text
    'Set all of the cell to regular text
    .Characters(Start:=1, Length:=0).Font.FontStyle = "Regular"
    
    'Set the first 2 characters to Bold
    .Characters(Start:=1, Length:=2).Font.FontStyle = "Bold"
End With
 
End Sub


Regards
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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