处理指定区域A2:E115
Sub 清除单格内部分文字()
On Error Resume Next ' 忽略报错
Dim r As Range
Dim count As Integer
Dim c As Characters
Dim str As String
For Each r In Range("A2:E115") '单元格范围 A2:E115
count = r.Characters.count
For i = 1 To count
'颜色非 0 直接去掉
If r.Characters(i, 1).Font.Color <> 0 Then
' 直接用空字符替换掉
'r.Characters(i, 1).Text = ""
' 换成红色#号,方便检查一下,然后直接用替换功能替换掉就行了。
r.Characters(i, 1).Text = "#"
r.Characters(i, 1).Font.Color = RGB(255, 0, 0)
End If
Next
Next
End Sub
处理选中
区域
Sub 清除选中区域中部分文字()
On Error Resume Next ' 忽略报错
For Each c In Selection.Cells
count = c.Characters.count
For i = 1 To count
'颜色非 0 直接去掉
If c.Characters(i, 1).Font.Color <> 0 Then '如果有需要也可以判断 Size
' 直接用空字符替换掉
'c.Characters(i, 1).Text = ""
' 换成红色#号,方便检查一下,然后直接用替换功能替换掉就行了。
c.Characters(i, 1).Text = "#"
c.Characters(i, 1).Font.Color = RGB(255, 0, 0)
End If
Next
Next
End Sub