是否有可能在Excel中查找和更改文本的颜色 [英] is it possible to find and change color of the text in excel

查看:113
本文介绍了是否有可能在Excel中查找和更改文本的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两列,第一列有一个城市名称列表,这些名称包含在下一个单元格的文本中.

I have two columns, the first column has a list of city names which are included next cell's text.

我想检查第二列的城市名称.为了简化起见,我想在第二列的文本中突出显示城市名称.

I want to check the second column for the city names. To make it easier I want to highlight city names in the second column's text.

我认为无法在Excel中突出显示文本中的单个单词.我想更改文本的颜色,以便于识别.我尝试了一些突出显示文本规则,但没有达到我想要的.

I don't think it is possible to highlight a single word in text in Excel. I want to change the colour of the text, for easy recognition. I tried some highlight text rules but did not achieve what I want.

有可能吗,如果可以,我该怎么做?

Is it possible, and if so, how can I do it?

推荐答案

您当然可以在B列内的A列中搜索字符串.

You can certainly search for the string in column A inside of Column B.

您对VBA代码有什么好处吗?这更多的是VBA项目.

Are you any good with VBA code? This is more of a VBA project.

这是选择和更改颜色的核心代码,但是您可以遍历目标单元格并查看它们每次可能位于的单元格范围.

Here is the core code for selection and color change, but you could loop through your target cells and look at the cell range where they could be located each time.

Sub test4String2color()
Dim strTest As String
Dim strLen As Integer
 strTest = Range("F1")
 strLen = Len(strTest)
For Each cell In Range("A1:D100")
 If InStr(cell, strTest) > 0 Then
  cell.Characters(InStr(cell, strTest), strLen).Font.Color = vbRed
 End If
Next
End Sub

这取自: https://stackoverflow.com/a/11676031/8716187

您知道如何使范围遍历文本以查找目标吗?确实,这是需要添加到此功能的内容,您可以将其链接到按钮或易于调用的内容.

Do you know how to make a range to loop through for the text to find targets? Really that is what would need to be added to this function which you can link to a button or something easy to call.

这篇关于是否有可能在Excel中查找和更改文本的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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