我需要的代码可以为只有自动的文本着色。具体来说,我的文字很干净,然后是蓝色和粗体的文字。我希望干净的文字变成红色,粗体,并带有删除线。这是我正在使用的代码,整个单元格都是干净的,蓝色粗体文本变成红色,粗体和穿透。
Sub KeepBlueBold()
'keeps bluebold cell
Dim Cell As Range
For Each Cell In Selection
KeepBlueAddRed Cell
Next Cell
End Sub
Sub KeepBlueAddRed(Cell As Range)
Dim iCh As Integer
For iCh = 1 To Len(Cell)
With Cell.Characters(iCh, 1)
If .FOnt.ColorIndex <> 1 Then
Text = Text & .Text
End If
End With
Next iCh
Cell.Value = Text
Cell.Characters.FOnt.Strikethrough = True
Cell.Characters.FOnt.Bold = True
Cell.Characters.FOnt.ColorIndex = 3
End Sub
答案 0 :(得分:0)
如果你已经选择了一个范围,下面的代码应该可以使用。
Sub KeepBlueBold()
Dim c As Range
For Each c In Selection.Cells
If c.Font.ColorIndex = 1 Then
c.Font.ColorIndex = 3
c.Font.Bold = True
c.Font.Strikethrough = True
End If
Next
End Sub