是否可以在Excel单元格中执行多个彩色文本? [英] Is it possible to do multiple colored text within an Excel cell?

查看:146
本文介绍了是否可以在Excel单元格中执行多个彩色文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有字符串strInfo,其中包含雇员约翰·迈巴赫。

I have string strInfo, which contains "Employee John Maybach".

如何使雇员部分黑色文本,红色?

How do I make the "Employee" part black text, and the "John Maybach" part red?

员工部分将始终保持不变,但员工姓名部分将更改,以便可以是2部分名称(John Doe)一个3部分的名字(John Allen Doe),或者只是一个名字(John)。

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).

我想让Employee一词总是黑色,的单元格中的文本,名称部分,为红色。这是可能吗?

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?

推荐答案

宏录音机是您的朋友:

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

这篇关于是否可以在Excel单元格中执行多个彩色文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆