Font style and color in a string

AJSIV4

New Member
Joined
Jan 29, 2013
Messages
4
Greetings,

I am imputing defined string variables into a cell. I need only certain parts of the text to be red and bold.

Example. Example.

HospSheet.Cells(curRow, DX_LABEL_COL).Value = PreDXLabel & "Billing DX:" & "RDXLabel & "Revised DX:"

PreDXLabel is fine as standard text, but everything else after the equals sign need to be red and bold.

The only solution I can find on other boards is making the cell active, which I would like to avoid, if possible.

Thanks!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hello.

With a macro?

Code:
Option Explicit
Sub Red_And_Bold()
'Start A2
Dim ingRow, ingRowStart, ingRowMax As Long

ingRowStart = 2
ingRowMax = ActiveSheet.Cells(Rows.Count, 3).End(xlUp).Row

  For ingRow = ingRowStart To ingRowMax
   If InStr(Cells(ingRow, 1), "=") > 0 Then
      With Cells(ingRow, 1)
       .Characters(Start:=InStr(Cells(ingRow, 1), "=") + 1, Length:=Len(Cells(ingRow, 1)) - InStr(Cells(ingRow, 1), "=")) _
       .Font.Bold = True
       .Font.ColorIndex = 3
      End With
    End If
  Next ingRow

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,845
Members
449,051
Latest member
excelquestion515

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