gpt4 book ai didi

string - 搜索匹配的文本字符串并更改字体颜色

转载 作者:行者123 更新时间:2023-12-04 20:17:48 26 4
gpt4 key购买 nike

我使用 Excel 已经 6 年了,我有点生疏了。这是我的场景:

我正在将问题列表导出到 Excel。我需要能够将单元格(多个值)中的关联链接号彼此区分开来。例如,我有两列,

Key = 一张票的号码

关联问题 = 关联的键

我需要一个语句来扫描 Key 列并在 Linked Issues 列中找到匹配项。然后,一旦找到匹配项,匹配的文本将采用 Key 的字体颜色。

复杂的地方在于 Linked Issues 列的每个单元格可能类似于 iss-3913、iss-3923、iss-1649。所以本质上扫描将是字符串中的匹配项。任何帮助表示赞赏。

最佳答案

对不起,我现在没有时间完成这个,但是这样的事情是否有助于第一列中每个单元格的循环?

编辑 :现在完成,第二次编辑更新到 B5 和 Z5,编辑 3 固定错误与列引用并更新以使用变量来分配要查看的列。

Sub colortext()
start_row = 5
key_col = 2
linked_col = 26
i = start_row 'start on row one
Do While Not IsEmpty(Cells(i, key_col)) 'Do until empty cell
o = start_row 'start with row one for second column
Do While Not IsEmpty(Cells(o, linked_col)) 'Do until empty cell
If Not InStr(1, Cells(o, linked_col), Cells(i, key_col)) = 0 Then 'if cell contents found in cell
With Cells(o, linked_col).Characters(Start:=InStr(1, Cells(o, linked_col), Cells(i, key_col)), Length:=Len(Cells(i, key_col))).Font
.Color = Cells(i, key_col).Font.Color 'change color of this part of the cell
End With
End If
o = o + 1 'increment the cell in second column
Loop
i = i + 1 'increment the cell in the first column
Loop
End Sub

或者可能

像这样的东西?

Excel VBA: change font color for specific char in a cell range

关于string - 搜索匹配的文本字符串并更改字体颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18000122/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com