Reputation: 4434
I have string strInfo, which contains "Employee John Maybach".
How do I make the "Employee" part black text, and the "John Maybach" part red?
The "Employee" part will always remain constant, but the employee's name part will change such that it may be a 2-part name (John Doe), or a 3-part name (John Allen Doe), or just a first name (John).
I want the word "Employee" to be always black, but the rest of the text in the cell, the name part, to be red. Is this possible?
Upvotes: 6
Views: 9008
Reputation: 328735
The macro recorder is your friend:
Dim fixedLength As Long
fixedLength = Len("Employee")
ActiveCell.FormulaR1C1 = "Employee Some Employee"
With ActiveCell.Characters(Start:=fixedLength + 2, Length:=Len(ActiveCell) - fixedLength - 1).Font
.Color = vbRed
End With
Upvotes: 7