how to bold a string variable

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
563
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
I'm probably tired or overthinking this, but how can I bold certain words inside a string or the entire string? Thank you
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
To bold the characters in a cell you select cell, and in the edit window select the sub text you want bolded and click the B in the home ribbon.
To do this with code
VBA Code:
Range("A1").Characters(3,4).Font.Bold = True
will make the 3rd, 4rh, 5th and 6th characters in A1 bold.

Note this will not work if the cell holds a formula. The result of formulas are all in the same font.
 
Upvote 0
My apologies. I should of explained what I was wanting to achieve much better than how I did.
VBA Code:
    Dim ctrl As MSForms.Control, cf As MSForms.Control
    Dim s As String
    
    For Each ctrl In Me.Controls
        s = ""
        If TypeName(ctrl) = "Frame" Then
            For Each cf In ctrl.Controls
                If "CheckBoxOptionButton" Like "*" & TypeName(cf) & "*" Then If cf.Value Then s = s & cf.Caption & ", "
            Next
          
            Select Case ctrl.Name
                Case Is = "frmTask"
                    If s <> "" Then MsgBox Left(s, Len(s) - 2) & " with " & frmSelectedItem & ";", vbInformation, ctrl.Name
                    If s <> "" Then Cells(lLastRow, "I") = s & "with " & frmSelectedItem & ";"
              
            End Select
        End If
    Next
I am wanting to bold whatever is inside the string "s". How can I do this? Also if you don't mind can you comment the working code given so I can learn from it please and thank you.
 
Upvote 0
Userform controls do not take rich text. That is, all the characters in any userform control will have the same font.
One cannot bold part of a TextBox.Text or CheckBox.Caption.
 
Upvote 0

Forum statistics

Threads
1,214,806
Messages
6,121,672
Members
449,045
Latest member
Marcus05

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