在Excel中用VBA代码实现, 关键在于如何判定这些文字中哪些是红色的
colorIndex=3
第1个回答 2007-11-21
例如删除单元格A1中的红色文字:
Sub abc()
Range("A1").Select
For i = 1 To Len(Cells(1, "A"))
If ActiveCell.Characters(Start:=i, Length:=1).Font.ColorIndex = 3 Then
ActiveCell.Characters(Start:=i, Length:=1).Delete
i = i - 1
End If
Next
End Sub
Sub abc()
Range("A1").Select
For i = 1 To Len(Cells(1, "A"))
If ActiveCell.Characters(Start:=i, Length:=1).Font.ColorIndex = 3 Then
ActiveCell.Characters(Start:=i, Length:=1).Delete
i = i - 1
End If
Next
End Sub