Colour section of sentence using VBA.

SEJTurner

New Member
Joined
Apr 16, 2021
Messages
1
Platform
  1. Windows
I'm using VBA/ combo boxes to fill in cells with different text depending on the selection made in the combo box.

The issue is that with one of the selections I need the last 3 words ij the cell to stand out, so they need be be a different colour and if possible bold. However the other words in the cell need to remain standard black and if other selections are made in combo box then full cell text must remain black.

Any suggestions on how I could do this?

Thanks
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Something like this:
VBA Code:
Private Sub CommandButton1_Click()
    Range("A1") = ComboBox1
    If ComboBox1 = "format ABC" Then 'The value you want to colour and boldface
        With Range("A1").Characters(Len(Range("A1")) - 2, 3).Font
            .Color = vbRed
            .Bold = True
        End With
    End If
    Unload Me
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,749
Members
448,989
Latest member
mariah3

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