我需要仅为自动着色文本的代码。具体来说,我有干净的文本,然后是蓝色和粗体的文本。我希望干净文本变成红色,粗体和删除线。这是我正在使用的代码,整个单元格都是干净的,蓝色的粗体文本变成红色,粗体和直线。Excel VBA仅为以前未着色的文本着色
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
您是否在任何给定的单元格中使用了混合格式? –
查找和替换不适合? – pnuts