gpt4 book ai didi

excel - 仅删除大单元格范围上的黑色文本字体

转载 作者:行者123 更新时间:2023-12-04 21:57:42 25 4
gpt4 key购买 nike

这就是我需要的:
我有超过 20.000 个单元格包含在黑色和红色的相同单元格文本中
我想删除单元格愤怒 A1:A20347 中包含的所有黑色文本(保持红色)。但我的日常行不通。一点帮助将不胜感激

Sub deleteonlyblacktextincell()

Range("A1:A20347").Select
For Each Cell In Selection
If Font.ColorIndex = 1 Then

' it is here where a want to delet only black text maintening other color text in the same cell

End If
Next
End Sub

最佳答案

您可以挑选字符颜色并单独测试它们:

Sub deleteonlyblacktextincell()

Range("A1:B20347").Select

For Each cell In Selection
Dim textOut As String
textOut = ""
For i = 1 To Len(cell)
If cell.Characters(i, 1).Font.ColorIndex <> 1 Then
textOut = textOut & Mid(cell, i, 1)
End If
Next
cell.Value = textOut
Next cell
End Sub

关于excel - 仅删除大单元格范围上的黑色文本字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41265299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com