小编use*_*002的帖子

如何使用VBA仅格式化单元格中字符串的一部分

目标是将这些值 A10、B10、C10、D10、E10、F10、G10、H10、I10、J1 更改为字体蓝色。

例如,“Yonge St A10、B10”,只有 A10 和 B10 的字体颜色应为蓝色,而“Yonge St”将保持黑色。

我有一个VBA代码。但是,代码更改了单元格中的所有文本颜色,而不是应更改的特定文本。见下文:

Dim i As Long
Dim sequences As String

' The sequence contains the values to highlight
sequences = "A10,B10,C10,D10,E10,F10,G10,H10,I10,J1"

' Split sequence list,  so it can loop through each value in the array

Dim seqList() As String
seqList = Split(sequences, ",")

' This loops through up to Row 20 to determine if the cell value contains a sequence value, if it does, then it highlights it blue
For …
Run Code Online (Sandbox Code Playgroud)

excel vba

5
推荐指数
1
解决办法
2982
查看次数

标签 统计

excel ×1

vba ×1