Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to do multiple colored text within an Excel cell?

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?

like image 894
phan Avatar asked Feb 27 '12 17:02

phan


People also ask

How to use multiple font colors or fonts in Excel?

Select the cell you want to apply multiple font colors or fonts, then get into the cell with pressing the F2 key (or just double click the cell). 2. Select the text you need to use different font colors or fonts, click Home > Font Color or Font in the Font group, then specify the certain font color or font you need.

How do I change the color of text in Excel?

Step 1: Select a range of cells you want to format the text color. After that Hover to Home Tab > Select Conditional Formatting (in Styles section) > Select Highlight Cells Rules (from the option menu) > Choose Equal to option.

How to conditionally format text that contains East in Excel?

In this case, for texts that contain East, we’ll format their text color. Step 1: Select the cells you want to conditionally format. Then Go to Home Tab > Select Conditional Formatting (from Styles section) > Select Highlight Cells Rules (from the option menu) > Choose Text that Contains option. Step 2: The Text that Contains dialog box pops up.

How do I change the color of text in a PDF?

Then highlight the text you want to change color and use the pop-up quick edit window (or right click on it to get it to show) and change the text color. Or you can use the Home->Edit ->text color.


1 Answers

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
like image 75
assylias Avatar answered Oct 05 '22 19:10

assylias