更改单元格范围中特定字符的字体颜色
我想更改一系列单元格内特定字符的字体颜色。我弄清楚了如何对单个单元格执行此操作(附有代码),但我无法弄清楚如何在整个单元格范围内执行此操作; B8:F12。有人可以帮忙吗?
谢谢!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer
Dim FindChar As String
Dim SearchString As String
SearchString = Range("B8").Value
FindChar = Chr(182)
For i = 1 To Len(SearchString)
If Mid(SearchString, i, 1) = FindChar Then
Range("B8").Characters(i, 1).Font.Color = RGB(221, 221, 221)
End If
Next i
End Sub
I would like to change the font color for a specific character within a range of cells. I figured out how to do this for a single cell (code attached), but I can't figure out how to do it over a full range of cells; B8: F12. Can anyone help?
thanks!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer
Dim FindChar As String
Dim SearchString As String
SearchString = Range("B8").Value
FindChar = Chr(182)
For i = 1 To Len(SearchString)
If Mid(SearchString, i, 1) = FindChar Then
Range("B8").Characters(i, 1).Font.Color = RGB(221, 221, 221)
End If
Next i
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调用
LoopAndChangeColorForThisRange
并查看它是否如您所期望的那样工作。Make a call to
LoopAndChangeColorForThisRange
and see if it works, as you'd expect.